From c4e22b1085fb41a31e7e87ff80d3cc1c0fd8b332 Mon Sep 17 00:00:00 2001 From: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com> Date: Tue, 31 Oct 2023 18:25:35 +0000 Subject: [PATCH 1/9] Fix warning when cookie is null --- src/Appwrite/Utopia/Request.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Appwrite/Utopia/Request.php b/src/Appwrite/Utopia/Request.php index a9eef62e06..cb877afad4 100644 --- a/src/Appwrite/Utopia/Request.php +++ b/src/Appwrite/Utopia/Request.php @@ -107,6 +107,10 @@ class Request extends UtopiaRequest { $headers = $this->generateHeaders(); + if (empty($this->swoole->cookie)) { + return $headers; + } + $cookieHeaders = []; foreach ($this->swoole->cookie as $key => $value) { $cookieHeaders[] = "{$key}={$value}"; From 7c8a9ad4d2f09de93e2b31ffbbb56a725a786e70 Mon Sep 17 00:00:00 2001 From: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com> Date: Tue, 31 Oct 2023 18:31:36 +0000 Subject: [PATCH 2/9] Fix incorrect general_protocol_unsupported error $requestHeaders was being referenced before it was set. This PR reverts code back to using $swooleRequest to extract the header. --- app/controllers/general.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index 247669731a..cf383b6710 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -408,7 +408,7 @@ App::init() * @see https://www.owasp.org/index.php/List_of_useful_HTTP_headers */ if (App::getEnv('_APP_OPTIONS_FORCE_HTTPS', 'disabled') === 'enabled') { // Force HTTPS - if ($request->getProtocol() !== 'https' && ($requestHeaders['host'] ?? '') !== 'localhost' && ($requestHeaders['host'] ?? '') !== APP_HOSTNAME_INTERNAL) { // localhost allowed for proxy, APP_HOSTNAME_INTERNAL allowed for migrations + if ($request->getProtocol() !== 'https' && ($swooleRequest->header['host'] ?? '') !== 'localhost' && ($swooleRequest->header['host'] ?? '') !== APP_HOSTNAME_INTERNAL) { // localhost allowed for proxy, APP_HOSTNAME_INTERNAL allowed for migrations if ($request->getMethod() !== Request::METHOD_GET) { throw new AppwriteException(AppwriteException::GENERAL_PROTOCOL_UNSUPPORTED, 'Method unsupported over HTTP. Please use HTTPS instead.'); } From 755699de8a554cf06a4910231a4186d2ca4844f1 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Tue, 31 Oct 2023 12:40:45 -0700 Subject: [PATCH 3/9] Bump appwrite version to 1.4.9 --- README-CN.md | 6 +++--- README.md | 6 +++--- app/init.php | 2 +- src/Appwrite/Migration/Migration.php | 1 + 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README-CN.md b/README-CN.md index 3881a8ac82..4a2f9edd65 100644 --- a/README-CN.md +++ b/README-CN.md @@ -66,7 +66,7 @@ docker run -it --rm \ --volume /var/run/docker.sock:/var/run/docker.sock \ --volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \ --entrypoint="install" \ - appwrite/appwrite:1.4.8 + appwrite/appwrite:1.4.9 ``` ### Windows @@ -78,7 +78,7 @@ docker run -it --rm ^ --volume //var/run/docker.sock:/var/run/docker.sock ^ --volume "%cd%"/appwrite:/usr/src/code/appwrite:rw ^ --entrypoint="install" ^ - appwrite/appwrite:1.4.8 + appwrite/appwrite:1.4.9 ``` #### PowerShell @@ -88,7 +88,7 @@ docker run -it --rm ` --volume /var/run/docker.sock:/var/run/docker.sock ` --volume ${pwd}/appwrite:/usr/src/code/appwrite:rw ` --entrypoint="install" ` - appwrite/appwrite:1.4.8 + appwrite/appwrite:1.4.9 ``` 运行后,可以在浏览器上访问 http://localhost 找到 Appwrite 控制台。在非 Linux 的本机主机上完成安装后,服务器可能需要几分钟才能启动。 diff --git a/README.md b/README.md index 9adc815bdd..9b4ba2bb58 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ docker run -it --rm \ --volume /var/run/docker.sock:/var/run/docker.sock \ --volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \ --entrypoint="install" \ - appwrite/appwrite:1.4.8 + appwrite/appwrite:1.4.9 ``` ### Windows @@ -88,7 +88,7 @@ docker run -it --rm ^ --volume //var/run/docker.sock:/var/run/docker.sock ^ --volume "%cd%"/appwrite:/usr/src/code/appwrite:rw ^ --entrypoint="install" ^ - appwrite/appwrite:1.4.8 + appwrite/appwrite:1.4.9 ``` #### PowerShell @@ -98,7 +98,7 @@ docker run -it --rm ` --volume /var/run/docker.sock:/var/run/docker.sock ` --volume ${pwd}/appwrite:/usr/src/code/appwrite:rw ` --entrypoint="install" ` - appwrite/appwrite:1.4.8 + appwrite/appwrite:1.4.9 ``` Once the Docker installation is complete, go to http://localhost to access the Appwrite console from your browser. Please note that on non-Linux native hosts, the server might take a few minutes to start after completing the installation. diff --git a/app/init.php b/app/init.php index 020af63761..e4b9e7573d 100644 --- a/app/init.php +++ b/app/init.php @@ -110,7 +110,7 @@ const APP_KEY_ACCCESS = 24 * 60 * 60; // 24 hours const APP_USER_ACCCESS = 24 * 60 * 60; // 24 hours const APP_CACHE_UPDATE = 24 * 60 * 60; // 24 hours const APP_CACHE_BUSTER = 515; -const APP_VERSION_STABLE = '1.4.8'; +const APP_VERSION_STABLE = '1.4.9'; const APP_DATABASE_ATTRIBUTE_EMAIL = 'email'; const APP_DATABASE_ATTRIBUTE_ENUM = 'enum'; const APP_DATABASE_ATTRIBUTE_IP = 'ip'; diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index 18f1a091c0..efa0fad8fb 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -73,6 +73,7 @@ abstract class Migration '1.4.6' => 'V19', '1.4.7' => 'V19', '1.4.8' => 'V19', + '1.4.9' => 'V19', ]; /** From 358fdb68782f5ba5c07993239cee338422793304 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Tue, 31 Oct 2023 12:43:52 -0700 Subject: [PATCH 4/9] Add 1.4.9 to CHANGES.md --- CHANGES.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 32ecd4f277..0363f28683 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,9 @@ +# Version 1.4.9 + +## Bug fixes + +* Fix 400 error on function domain execution in [#7059](https://github.com/appwrite/appwrite/pull/7059) + # Version 1.4.8 ## Notable changes From 74450b1178413958f3c5378a057b755e98b1d6a7 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 1 Nov 2023 18:29:54 +1300 Subject: [PATCH 5/9] Enum tests --- composer.json | 2 +- composer.lock | 29 ++++++++++++++++++---------- src/Appwrite/Platform/Tasks/SDKs.php | 27 +++++++++++++------------- 3 files changed, 34 insertions(+), 24 deletions(-) diff --git a/composer.json b/composer.json index 4ce175abea..e76948287e 100644 --- a/composer.json +++ b/composer.json @@ -86,7 +86,7 @@ ], "require-dev": { "ext-fileinfo": "*", - "appwrite/sdk-generator": "0.35.*", + "appwrite/sdk-generator": "dev-feat-whitelist-enums as 0.35.2", "phpunit/phpunit": "9.5.20", "squizlabs/php_codesniffer": "^3.7", "swoole/ide-helper": "5.0.2", diff --git a/composer.lock b/composer.lock index e8334179ff..7161efe714 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": "9afc62ce9c6ba587b9c028e11494e026", + "content-hash": "31937ddcd75e14c0af8d387941678509", "packages": [ { "name": "adhocore/jwt", @@ -3136,16 +3136,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.35.2", + "version": "dev-feat-whitelist-enums", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "2dfe0430a64ffd2a07078d83b20144b871acac3b" + "reference": "c921cbbcfb5ef16305c6455fe5ca27fdab75c00a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/2dfe0430a64ffd2a07078d83b20144b871acac3b", - "reference": "2dfe0430a64ffd2a07078d83b20144b871acac3b", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/c921cbbcfb5ef16305c6455fe5ca27fdab75c00a", + "reference": "c921cbbcfb5ef16305c6455fe5ca27fdab75c00a", "shasum": "" }, "require": { @@ -3181,9 +3181,9 @@ "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", "support": { "issues": "https://github.com/appwrite/sdk-generator/issues", - "source": "https://github.com/appwrite/sdk-generator/tree/0.35.2" + "source": "https://github.com/appwrite/sdk-generator/tree/feat-whitelist-enums" }, - "time": "2023-09-14T14:59:50+00:00" + "time": "2023-11-01T04:40:27+00:00" }, { "name": "doctrine/deprecations", @@ -5796,9 +5796,18 @@ "time": "2023-08-28T11:09:02+00:00" } ], - "aliases": [], + "aliases": [ + { + "package": "appwrite/sdk-generator", + "version": "dev-feat-whitelist-enums", + "alias": "0.35.2", + "alias_normalized": "0.35.2.0" + } + ], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "appwrite/sdk-generator": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { @@ -5822,5 +5831,5 @@ "platform-overrides": { "php": "8.0" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/src/Appwrite/Platform/Tasks/SDKs.php b/src/Appwrite/Platform/Tasks/SDKs.php index a052acf373..2122a1cb9c 100644 --- a/src/Appwrite/Platform/Tasks/SDKs.php +++ b/src/Appwrite/Platform/Tasks/SDKs.php @@ -252,19 +252,20 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND } if ($git && !empty($gitUrl)) { - \exec('rm -rf ' . $target . ' && \ - mkdir -p ' . $target . ' && \ - cd ' . $target . ' && \ - git init --initial-branch=' . $gitBranch . ' && \ - git remote add origin ' . $gitUrl . ' && \ - git fetch origin ' . $gitBranch . ' && \ - git pull origin ' . $gitBranch . ' && \ - rm -rf ' . $target . '/* && \ - cp -r ' . $result . '/* ' . $target . '/ && \ - git add . && \ - git commit -m "' . $message . '" && \ - git push -u origin ' . $gitBranch . ' - '); + \exec(" + rm -rf $target + mkdir -p $target + cd $target + git init --initial-branch=$gitBranch + git remote add origin $gitUrl + git fetch origin $gitBranch + git pull origin $gitBranch + rm -rf $target/* + cp -r $result/* $target/ + git add . + git commit -m \"$message\" + git push -u origin $gitBranch + "); Console::success("Pushed {$language['name']} SDK to {$gitUrl}"); From 3652ab61d8bb275a33b2ef52008104a3ba22e89a Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 1 Nov 2023 21:02:42 +1300 Subject: [PATCH 6/9] Revert "Enum tests" This reverts commit 74450b1178413958f3c5378a057b755e98b1d6a7. --- composer.json | 2 +- composer.lock | 29 ++++++++++------------------ src/Appwrite/Platform/Tasks/SDKs.php | 27 +++++++++++++------------- 3 files changed, 24 insertions(+), 34 deletions(-) diff --git a/composer.json b/composer.json index e76948287e..4ce175abea 100644 --- a/composer.json +++ b/composer.json @@ -86,7 +86,7 @@ ], "require-dev": { "ext-fileinfo": "*", - "appwrite/sdk-generator": "dev-feat-whitelist-enums as 0.35.2", + "appwrite/sdk-generator": "0.35.*", "phpunit/phpunit": "9.5.20", "squizlabs/php_codesniffer": "^3.7", "swoole/ide-helper": "5.0.2", diff --git a/composer.lock b/composer.lock index 7161efe714..e8334179ff 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": "31937ddcd75e14c0af8d387941678509", + "content-hash": "9afc62ce9c6ba587b9c028e11494e026", "packages": [ { "name": "adhocore/jwt", @@ -3136,16 +3136,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "dev-feat-whitelist-enums", + "version": "0.35.2", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "c921cbbcfb5ef16305c6455fe5ca27fdab75c00a" + "reference": "2dfe0430a64ffd2a07078d83b20144b871acac3b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/c921cbbcfb5ef16305c6455fe5ca27fdab75c00a", - "reference": "c921cbbcfb5ef16305c6455fe5ca27fdab75c00a", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/2dfe0430a64ffd2a07078d83b20144b871acac3b", + "reference": "2dfe0430a64ffd2a07078d83b20144b871acac3b", "shasum": "" }, "require": { @@ -3181,9 +3181,9 @@ "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", "support": { "issues": "https://github.com/appwrite/sdk-generator/issues", - "source": "https://github.com/appwrite/sdk-generator/tree/feat-whitelist-enums" + "source": "https://github.com/appwrite/sdk-generator/tree/0.35.2" }, - "time": "2023-11-01T04:40:27+00:00" + "time": "2023-09-14T14:59:50+00:00" }, { "name": "doctrine/deprecations", @@ -5796,18 +5796,9 @@ "time": "2023-08-28T11:09:02+00:00" } ], - "aliases": [ - { - "package": "appwrite/sdk-generator", - "version": "dev-feat-whitelist-enums", - "alias": "0.35.2", - "alias_normalized": "0.35.2.0" - } - ], + "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "appwrite/sdk-generator": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { @@ -5831,5 +5822,5 @@ "platform-overrides": { "php": "8.0" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" } diff --git a/src/Appwrite/Platform/Tasks/SDKs.php b/src/Appwrite/Platform/Tasks/SDKs.php index 2122a1cb9c..a052acf373 100644 --- a/src/Appwrite/Platform/Tasks/SDKs.php +++ b/src/Appwrite/Platform/Tasks/SDKs.php @@ -252,20 +252,19 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND } if ($git && !empty($gitUrl)) { - \exec(" - rm -rf $target - mkdir -p $target - cd $target - git init --initial-branch=$gitBranch - git remote add origin $gitUrl - git fetch origin $gitBranch - git pull origin $gitBranch - rm -rf $target/* - cp -r $result/* $target/ - git add . - git commit -m \"$message\" - git push -u origin $gitBranch - "); + \exec('rm -rf ' . $target . ' && \ + mkdir -p ' . $target . ' && \ + cd ' . $target . ' && \ + git init --initial-branch=' . $gitBranch . ' && \ + git remote add origin ' . $gitUrl . ' && \ + git fetch origin ' . $gitBranch . ' && \ + git pull origin ' . $gitBranch . ' && \ + rm -rf ' . $target . '/* && \ + cp -r ' . $result . '/* ' . $target . '/ && \ + git add . && \ + git commit -m "' . $message . '" && \ + git push -u origin ' . $gitBranch . ' + '); Console::success("Pushed {$language['name']} SDK to {$gitUrl}"); From 9f7bbe48691eea111e8189622b6b32514d919e4f Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Fri, 3 Nov 2023 16:57:30 +0000 Subject: [PATCH 7/9] Fix the Health service's get X queue endpoints Before this, the endpoints called $client->sumProcessingJobs() which only gets the currently processing jobs, but this endpoint should return what's currently in queue, pending to be processed. This should be retrieved using $client->getQueueSize(). --- app/controllers/api/health.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index 8ca1371488..b1195cd878 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -352,7 +352,7 @@ App::get('/v1/health/queue/webhooks') ->inject('response') ->action(function (Connection $queue, Response $response) { $client = new Client(Event::WEBHOOK_QUEUE_NAME, $queue); - $response->dynamic(new Document([ 'size' => $client->sumProcessingJobs() ]), Response::MODEL_HEALTH_QUEUE); + $response->dynamic(new Document([ 'size' => $client->getQueueSize() ]), Response::MODEL_HEALTH_QUEUE); }, ['response']); App::get('/v1/health/queue/logs') @@ -370,7 +370,7 @@ App::get('/v1/health/queue/logs') ->inject('response') ->action(function (Connection $queue, Response $response) { $client = new Client(Event::AUDITS_QUEUE_NAME, $queue); - $response->dynamic(new Document([ 'size' => $client->sumProcessingJobs() ]), Response::MODEL_HEALTH_QUEUE); + $response->dynamic(new Document([ 'size' => $client->getQueueSize() ]), Response::MODEL_HEALTH_QUEUE); }, ['response']); App::get('/v1/health/queue/certificates') @@ -388,7 +388,7 @@ App::get('/v1/health/queue/certificates') ->inject('response') ->action(function (Connection $queue, Response $response) { $client = new Client(Event::CERTIFICATES_QUEUE_NAME, $queue); - $response->dynamic(new Document([ 'size' => $client->sumProcessingJobs() ]), Response::MODEL_HEALTH_QUEUE); + $response->dynamic(new Document([ 'size' => $client->getQueueSize() ]), Response::MODEL_HEALTH_QUEUE); }, ['response']); App::get('/v1/health/queue/builds') @@ -406,7 +406,7 @@ App::get('/v1/health/queue/builds') ->inject('response') ->action(function (Connection $queue, Response $response) { $client = new Client(Event::BUILDS_QUEUE_NAME, $queue); - $response->dynamic(new Document([ 'size' => $client->sumProcessingJobs() ]), Response::MODEL_HEALTH_QUEUE); + $response->dynamic(new Document([ 'size' => $client->getQueueSize() ]), Response::MODEL_HEALTH_QUEUE); }, ['response']); App::get('/v1/health/queue/databases') @@ -425,7 +425,7 @@ App::get('/v1/health/queue/databases') ->inject('response') ->action(function (string $name, Connection $queue, Response $response) { $client = new Client($name, $queue); - $response->dynamic(new Document([ 'size' => $client->sumProcessingJobs() ]), Response::MODEL_HEALTH_QUEUE); + $response->dynamic(new Document([ 'size' => $client->getQueueSize() ]), Response::MODEL_HEALTH_QUEUE); }, ['response']); App::get('/v1/health/queue/deletes') @@ -443,7 +443,7 @@ App::get('/v1/health/queue/deletes') ->inject('response') ->action(function (Connection $queue, Response $response) { $client = new Client(Event::DELETE_QUEUE_NAME, $queue); - $response->dynamic(new Document([ 'size' => $client->sumProcessingJobs() ]), Response::MODEL_HEALTH_QUEUE); + $response->dynamic(new Document([ 'size' => $client->getQueueSize() ]), Response::MODEL_HEALTH_QUEUE); }, ['response']); App::get('/v1/health/queue/mails') @@ -461,7 +461,7 @@ App::get('/v1/health/queue/mails') ->inject('response') ->action(function (Connection $queue, Response $response) { $client = new Client(Event::MAILS_QUEUE_NAME, $queue); - $response->dynamic(new Document([ 'size' => $client->sumProcessingJobs() ]), Response::MODEL_HEALTH_QUEUE); + $response->dynamic(new Document([ 'size' => $client->getQueueSize() ]), Response::MODEL_HEALTH_QUEUE); }, ['response']); App::get('/v1/health/queue/messaging') @@ -479,7 +479,7 @@ App::get('/v1/health/queue/messaging') ->inject('response') ->action(function (Connection $queue, Response $response) { $client = new Client(Event::MESSAGING_QUEUE_NAME, $queue); - $response->dynamic(new Document([ 'size' => $client->sumProcessingJobs() ]), Response::MODEL_HEALTH_QUEUE); + $response->dynamic(new Document([ 'size' => $client->getQueueSize() ]), Response::MODEL_HEALTH_QUEUE); }, ['response']); App::get('/v1/health/queue/migrations') @@ -497,7 +497,7 @@ App::get('/v1/health/queue/migrations') ->inject('response') ->action(function (Connection $queue, Response $response) { $client = new Client(Event::MIGRATIONS_QUEUE_NAME, $queue); - $response->dynamic(new Document([ 'size' => $client->sumProcessingJobs() ]), Response::MODEL_HEALTH_QUEUE); + $response->dynamic(new Document([ 'size' => $client->getQueueSize() ]), Response::MODEL_HEALTH_QUEUE); }, ['response']); App::get('/v1/health/queue/functions') @@ -515,7 +515,7 @@ App::get('/v1/health/queue/functions') ->inject('response') ->action(function (Connection $queue, Response $response) { $client = new Client(Event::FUNCTIONS_QUEUE_NAME, $queue); - $response->dynamic(new Document([ 'size' => $client->sumProcessingJobs() ]), Response::MODEL_HEALTH_QUEUE); + $response->dynamic(new Document([ 'size' => $client->getQueueSize() ]), Response::MODEL_HEALTH_QUEUE); }, ['response']); App::get('/v1/health/storage/local') From 03da0380ea8bfc11d2d5611a9b416128245b98cc Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Fri, 3 Nov 2023 17:47:16 +0000 Subject: [PATCH 8/9] Ensure schedules for deleted projects are deleted --- src/Appwrite/Platform/Workers/Deletes.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 2130499257..b699ba9e17 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -178,7 +178,8 @@ class Deletes extends Action $project = $dbForConsole->getDocument('projects', $document->getAttribute('projectId')); if ($project->isEmpty()) { - Console::warning('Unable to delete schedule for function ' . $document->getAttribute('resourceId')); + $dbForConsole->deleteDocument('schedules', $document->getId()); + Console::success('Deleted schedule for deleted project ' . $document->getAttribute('projectId')); return; } From 30b8ff9166f17aba3450fbbafc6caaf4a58c380d Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Fri, 3 Nov 2023 17:47:52 +0000 Subject: [PATCH 9/9] Add pagination to listByGroup to fix infinite loop problem --- src/Appwrite/Platform/Workers/Deletes.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index b699ba9e17..b91ddb901a 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -921,17 +921,28 @@ class Deletes extends Action $count = 0; $chunk = 0; $limit = 50; + $results = []; $sum = $limit; + $cursor = null; $executionStart = \microtime(true); while ($sum === $limit) { $chunk++; - $results = $database->find($collection, \array_merge([Query::limit($limit)], $queries)); + $mergedQueries = \array_merge([Query::limit($limit)], $queries); + if ($cursor instanceof Document) { + $mergedQueries[] = Query::cursorAfter($cursor); + } + + $results = $database->find($collection, $mergedQueries); $sum = count($results); + if ($sum > 0) { + $cursor = $results[$sum - 1]; + } + foreach ($results as $document) { if (is_callable($callback)) { $callback($document);