diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 2d32a40bb8..73d38ed9fc 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -109,7 +109,7 @@ App::post('/v1/functions') ); $functionsDomain = App::getEnv('_APP_DOMAIN_FUNCTIONS', 'disabled'); - if($functionsDomain !== 'disabled') { + if ($functionsDomain !== 'disabled') { $ruleId = ID::unique(); $routeSubdomain = ID::unique(); $domain = "{$routeSubdomain}.{$functionsDomain}"; @@ -1194,7 +1194,7 @@ App::post('/v1/functions/:functionId/executions') $agent = ''; foreach ($headers as $header => $value) { - if(\strtolower($header) === 'user-agent') { + if (\strtolower($header) === 'user-agent') { $agent = $value; } } @@ -1218,7 +1218,7 @@ App::post('/v1/functions/:functionId/executions') 'agent' => $agent ]); - if($function->getAttribute('logging')) { + if ($function->getAttribute('logging')) { /** @var Document $execution */ $execution = Authorization::skip(fn () => $dbForProject->createDocument('executions', $execution)); } @@ -1335,7 +1335,7 @@ App::post('/v1/functions/:functionId/executions') Console::error($th->getMessage()); } - if($function->getAttribute('logging')) { + if ($function->getAttribute('logging')) { Authorization::skip(fn () => $dbForProject->updateDocument('executions', $executionId, $execution)); } diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index c9e420f49f..63664f521a 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -1160,4 +1160,4 @@ App::delete('/v1/projects/:projectId/platforms/:platformId') $dbForConsole->deleteCachedDocument('projects', $project->getId()); $response->noContent(); - }); \ No newline at end of file + }); diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index d63057239b..f5365ae92c 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -47,11 +47,11 @@ App::post('/v1/proxy/rules') ]); if ($document && !$document->isEmpty()) { - if($document->getAttribute('projectId') === $project->getId()) { + if ($document->getAttribute('projectId') === $project->getId()) { $resourceType = $document->getAttribute('resourceType'); $resourceId = $document->getAttribute('resourceId'); $message = "Domain already assigned to '{$resourceType}' service"; - if(!empty($resourceId)) { + if (!empty($resourceId)) { $message .= " with ID '{$resourceId}'"; } @@ -59,14 +59,14 @@ App::post('/v1/proxy/rules') } else { $message = "Domain already assigned to different project."; } - + throw new Exception(Exception::RULE_ALREADY_EXISTS, $message); } $resourceInternalId = ''; - if($resourceType == 'function') { - if(empty($resourceId)) { + if ($resourceType == 'function') { + if (empty($resourceId)) { throw new Exception(Exception::RULE_RESOURCE_ID_MISSING); } @@ -85,7 +85,7 @@ App::post('/v1/proxy/rules') $status = 'created'; $functionsDomain = App::getEnv('_APP_DOMAIN_FUNCTIONS', 'disabled'); - if($functionsDomain !== 'disabled' && \str_ends_with($domain->get(), $functionsDomain)) { + if ($functionsDomain !== 'disabled' && \str_ends_with($domain->get(), $functionsDomain)) { $status = 'verified'; } @@ -291,4 +291,4 @@ App::patch('/v1/proxy/rules/:ruleId/verification') $rule->setAttribute('logs', $certificate->getAttribute('logs', '')); $response->dynamic($rule, Response::MODEL_PROXY_RULE); - }); \ No newline at end of file + }); diff --git a/app/controllers/general.php b/app/controllers/general.php index efac71dfa3..dd62d9b15d 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -43,7 +43,8 @@ Config::setParam('domainVerification', false); Config::setParam('cookieDomain', 'localhost'); Config::setParam('cookieSamesite', Response::COOKIE_SAMESITE_NONE); -function router(Database $dbForConsole, SwooleRequest $swooleRequest, Response $response) { +function router(Database $dbForConsole, SwooleRequest $swooleRequest, Response $response) +{ $host = $swooleRequest->header['host'] ?? ''; $route = Authorization::skip( @@ -53,7 +54,7 @@ function router(Database $dbForConsole, SwooleRequest $swooleRequest, Response $ ]) )[0] ?? null; - if($route === null) { + if ($route === null) { throw new AppwriteException(AppwriteException::ROUTER_UNKNOWN_HOST); } @@ -61,28 +62,28 @@ function router(Database $dbForConsole, SwooleRequest $swooleRequest, Response $ $project = Authorization::skip( fn() => $dbForConsole->getDocument('projects', $projectId) ); - if(array_key_exists('proxy', $project->getAttribute('services', []))) { + if (array_key_exists('proxy', $project->getAttribute('services', []))) { $status = $project->getAttribute('services', [])['proxy']; - if(!$status) { + if (!$status) { throw new AppwriteException(AppwriteException::GENERAL_SERVICE_DISABLED); } } // Skip Appwrite Router for ACME challenge. Nessessary for certificate generation $path = ($swooleRequest->server['request_uri'] ?? ''); - if(\str_starts_with($path, '/.well-known/acme-challenge')) { + if (\str_starts_with($path, '/.well-known/acme-challenge')) { return false; } $type = $route->getAttribute('resourceType'); - if($type === 'function') { + if ($type === 'function') { $functionId = $route->getAttribute('resourceId'); $projectId = $route->getAttribute('projectId'); $path = ($swooleRequest->server['request_uri'] ?? ''); $query = ($swooleRequest->server['query_string'] ?? ''); - if(!empty($query)) { + if (!empty($query)) { $path .= '?' . $query; } @@ -141,7 +142,7 @@ function router(Database $dbForConsole, SwooleRequest $swooleRequest, Response $ $response->setStatusCode($execution['statusCode'] ?? 200)->send($body); return true; - } else if($type === 'api') { + } elseif ($type === 'api') { return false; } else { throw new AppwriteException(AppwriteException::ROUTER_INVALID_TYPE); @@ -171,8 +172,8 @@ App::init() $host = $swooleRequest->header['host'] ?? ''; $mainDomain = App::getEnv('_APP_DOMAIN', ''); // Only run Router when external domain - if($host !== $mainDomain && $host !== 'localhost') { - if(router($dbForConsole, $swooleRequest, $response)) { + if ($host !== $mainDomain && $host !== 'localhost') { + if (router($dbForConsole, $swooleRequest, $response)) { return; } } @@ -461,8 +462,8 @@ App::options() $host = $swooleRequest->header['host'] ?? ''; $mainDomain = App::getEnv('_APP_DOMAIN', ''); // Only run Router when external domain - if($host !== $mainDomain && $host !== 'localhost') { - if(router($dbForConsole, $swooleRequest, $response)) { + if ($host !== $mainDomain && $host !== 'localhost') { + if (router($dbForConsole, $swooleRequest, $response)) { return; } } diff --git a/app/workers/certificates.php b/app/workers/certificates.php index 3a5cebea61..7bcb13fb9c 100644 --- a/app/workers/certificates.php +++ b/app/workers/certificates.php @@ -410,7 +410,7 @@ class CertificatesV1 extends Worker Query::equal('domain', [$domain]), ]); - if(!$rule->isEmpty()) { + if (!$rule->isEmpty()) { $rule->setAttribute('certificateId', $certificateId); $rule->setAttribute('status', $success ? 'verified' : 'unverified'); $this->dbForConsole->updateDocument('rules', $rule->getId(), $rule); diff --git a/app/workers/deletes.php b/app/workers/deletes.php index 6fdefacc74..904824b596 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -462,7 +462,7 @@ class DeletesV1 extends Worker Query::equal('resourceType', ['function']), Query::equal('resourceInternalId', [$document->getInternalId()]), Query::equal('projectInternalId', [$project->getInternalId()]) - ], $dbForConsole, function(Document $document) use ($project) { + ], $dbForConsole, function (Document $document) use ($project) { $this->deleteRule($document, $project); }); @@ -737,10 +737,11 @@ class DeletesV1 extends Worker $device->deletePath($document->getId()); } - protected function deleteRuntimes(?Document $function, Document $project) { + protected function deleteRuntimes(?Document $function, Document $project) + { $executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST')); - $deleteByFunction = function(Document $function) use ($project, $executor) { + $deleteByFunction = function (Document $function) use ($project, $executor) { $this->listByGroup( 'deployments', [ @@ -765,7 +766,7 @@ class DeletesV1 extends Worker ); }; - if($function !== null) { + if ($function !== null) { // Delete function runtimes $deleteByFunction($function); } else { diff --git a/app/workers/functions.php b/app/workers/functions.php index 5ea5b3f62e..1dd7d94628 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -82,11 +82,11 @@ Server::setResource('execute', function () { if ($execution->isEmpty()) { $agent = ''; foreach ($headers as $header => $value) { - if(\strtolower($header) === 'user-agent') { + if (\strtolower($header) === 'user-agent') { $agent = $value; } } - + $executionId = ID::unique(); $execution = new Document([ '$id' => $executionId, @@ -105,7 +105,7 @@ Server::setResource('execute', function () { 'agent' => $agent ]); - if($function->getAttribute('logging')) { + if ($function->getAttribute('logging')) { $execution = $dbForProject->createDocument('executions', $execution); } @@ -116,10 +116,10 @@ Server::setResource('execute', function () { } } - if($execution->getAttribute('status') !== 'processing') { + if ($execution->getAttribute('status') !== 'processing') { $execution->setAttribute('status', 'processing'); - if($function->getAttribute('logging')) { + if ($function->getAttribute('logging')) { $execution = $dbForProject->updateDocument('executions', $executionId, $execution); } } @@ -158,7 +158,7 @@ Server::setResource('execute', function () { ]); $body = $vars['APPWRITE_FUNCTION_EVENT_DATA'] ?? ''; - if(empty($body)) { + if (empty($body)) { $body = $vars['APPWRITE_FUNCTION_DATA'] ?? ''; } @@ -203,7 +203,7 @@ Server::setResource('execute', function () { Console::error($th->getMessage()); } - if($function->getAttribute('logging')) { + if ($function->getAttribute('logging')) { $execution = $dbForProject->updateDocument('executions', $executionId, $execution); } diff --git a/composer.lock b/composer.lock index 6af8bb1e3a..24fb668be4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "044fff24a3403c0406cdf69a94a6e76f", + "content-hash": "e8e64d67c559b26264b6a89ebab1ab72", "packages": [ { "name": "adhocore/jwt", @@ -620,16 +620,16 @@ }, { "name": "guzzlehttp/psr7", - "version": "2.4.3", + "version": "2.4.4", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "67c26b443f348a51926030c83481b85718457d3d" + "reference": "3cf1b6d4f0c820a2cf8bcaec39fc698f3443b5cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/67c26b443f348a51926030c83481b85718457d3d", - "reference": "67c26b443f348a51926030c83481b85718457d3d", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/3cf1b6d4f0c820a2cf8bcaec39fc698f3443b5cf", + "reference": "3cf1b6d4f0c820a2cf8bcaec39fc698f3443b5cf", "shasum": "" }, "require": { @@ -719,7 +719,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.4.3" + "source": "https://github.com/guzzle/psr7/tree/2.4.4" }, "funding": [ { @@ -735,7 +735,7 @@ "type": "tidelift" } ], - "time": "2022-10-26T14:07:24+00:00" + "time": "2023-03-09T13:19:02+00:00" }, { "name": "influxdb/influxdb-php", @@ -1404,54 +1404,6 @@ }, "time": "2020-04-16T16:39:50+00:00" }, - { - "name": "selective/base32", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/selective-php/base32.git", - "reference": "8da7955d3cc835f653c25dd516e39f61f2a6046a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/selective-php/base32/zipball/8da7955d3cc835f653c25dd516e39f61f2a6046a", - "reference": "8da7955d3cc835f653c25dd516e39f61f2a6046a", - "shasum": "" - }, - "require": { - "php": ">=7.1.3" - }, - "require-dev": { - "overtrue/phplint": "^1.1", - "phpstan/phpstan": "*", - "phpunit/phpunit": "^6|^7", - "squizlabs/php_codesniffer": "^3.4" - }, - "type": "library", - "autoload": { - "psr-4": { - "Selective\\Base32\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Base32 based on RFC 4648", - "homepage": "https://github.com/selective-php/base32", - "keywords": [ - "base32", - "decode", - "encode", - "encoder", - "encoding" - ], - "support": { - "issues": "https://github.com/selective-php/base32/issues", - "source": "https://github.com/selective-php/base32/tree/master" - }, - "time": "2020-04-03T20:48:25+00:00" - }, { "name": "slickdeals/statsd", "version": "3.1.0", @@ -1510,16 +1462,16 @@ }, { "name": "symfony/deprecation-contracts", - "version": "v3.2.0", + "version": "v3.2.1", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "1ee04c65529dea5d8744774d474e7cbd2f1206d3" + "reference": "e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/1ee04c65529dea5d8744774d474e7cbd2f1206d3", - "reference": "1ee04c65529dea5d8744774d474e7cbd2f1206d3", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e", + "reference": "e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e", "shasum": "" }, "require": { @@ -1557,7 +1509,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.2.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.2.1" }, "funding": [ { @@ -1573,7 +1525,7 @@ "type": "tidelift" } ], - "time": "2022-11-25T10:21:52+00:00" + "time": "2023-03-01T10:25:55+00:00" }, { "name": "utopia-php/abuse", @@ -2889,12 +2841,12 @@ "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "f2c7387b99ecd4ea39d2d18903c07c2a911a93f8" + "reference": "fb483b33b538111d7ba6881c4b36264a57b323ad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/f2c7387b99ecd4ea39d2d18903c07c2a911a93f8", - "reference": "f2c7387b99ecd4ea39d2d18903c07c2a911a93f8", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/fb483b33b538111d7ba6881c4b36264a57b323ad", + "reference": "fb483b33b538111d7ba6881c4b36264a57b323ad", "shasum": "" }, "require": { @@ -2932,7 +2884,7 @@ "issues": "https://github.com/appwrite/sdk-generator/issues", "source": "https://github.com/appwrite/sdk-generator/tree/feat-add-path-keyword" }, - "time": "2023-02-15T13:06:27+00:00" + "time": "2023-02-21T15:02:58+00:00" }, { "name": "doctrine/instantiator", @@ -3130,16 +3082,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.11.0", + "version": "1.11.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614" + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614", - "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", "shasum": "" }, "require": { @@ -3177,7 +3129,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0" + "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" }, "funding": [ { @@ -3185,20 +3137,20 @@ "type": "tidelift" } ], - "time": "2022-03-03T13:19:32+00:00" + "time": "2023-03-08T13:26:56+00:00" }, { "name": "nikic/php-parser", - "version": "v4.15.3", + "version": "v4.15.4", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "570e980a201d8ed0236b0a62ddf2c9cbb2034039" + "reference": "6bb5176bc4af8bcb7d926f88718db9b96a2d4290" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/570e980a201d8ed0236b0a62ddf2c9cbb2034039", - "reference": "570e980a201d8ed0236b0a62ddf2c9cbb2034039", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/6bb5176bc4af8bcb7d926f88718db9b96a2d4290", + "reference": "6bb5176bc4af8bcb7d926f88718db9b96a2d4290", "shasum": "" }, "require": { @@ -3239,9 +3191,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.3" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.4" }, - "time": "2023-01-16T22:05:37+00:00" + "time": "2023-03-05T19:49:14+00:00" }, { "name": "phar-io/manifest", @@ -3589,23 +3541,23 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.24", + "version": "9.2.26", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "2cf940ebc6355a9d430462811b5aaa308b174bed" + "reference": "443bc6912c9bd5b409254a40f4b0f4ced7c80ea1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2cf940ebc6355a9d430462811b5aaa308b174bed", - "reference": "2cf940ebc6355a9d430462811b5aaa308b174bed", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/443bc6912c9bd5b409254a40f4b0f4ced7c80ea1", + "reference": "443bc6912c9bd5b409254a40f4b0f4ced7c80ea1", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.14", + "nikic/php-parser": "^4.15", "php": ">=7.3", "phpunit/php-file-iterator": "^3.0.3", "phpunit/php-text-template": "^2.0.2", @@ -3620,8 +3572,8 @@ "phpunit/phpunit": "^9.3" }, "suggest": { - "ext-pcov": "*", - "ext-xdebug": "*" + "ext-pcov": "PHP extension that provides line coverage", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" }, "type": "library", "extra": { @@ -3654,7 +3606,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.24" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.26" }, "funding": [ { @@ -3662,7 +3614,7 @@ "type": "github" } ], - "time": "2023-01-26T08:26:55+00:00" + "time": "2023-03-06T12:58:08+00:00" }, { "name": "phpunit/php-file-iterator", @@ -4974,16 +4926,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.7.1", + "version": "3.7.2", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619" + "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1359e176e9307e906dc3d890bcc9603ff6d90619", - "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879", + "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879", "shasum": "" }, "require": { @@ -5019,14 +4971,15 @@ "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", "keywords": [ "phpcs", - "standards" + "standards", + "static analysis" ], "support": { "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", "source": "https://github.com/squizlabs/PHP_CodeSniffer", "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" }, - "time": "2022-06-18T07:21:10+00:00" + "time": "2023-02-22T23:07:41+00:00" }, { "name": "swoole/ide-helper",