From 8e7cc6ed1470fc859432ed5be66c6c58b6c7fa8a Mon Sep 17 00:00:00 2001 From: Binyamin Yawitz <316103+byawitz@users.noreply.github.com> Date: Thu, 8 Aug 2024 09:25:56 -0400 Subject: [PATCH 1/9] fix: Moving migration to be inside coroutine completely --- src/Appwrite/Migration/Migration.php | 44 ++++++++++++------------- src/Appwrite/Migration/Version/V19.php | 38 ++++++++++----------- src/Appwrite/Platform/Tasks/Migrate.php | 22 +++++++------ 3 files changed, 51 insertions(+), 53 deletions(-) diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index a0accaf6776..539282387d3 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -171,29 +171,27 @@ public function forEachDocument(callable $callback): void Console::log('Migrating Collection ' . $collection['$id'] . ':'); - \Co\run(function (array $collection, callable $callback) { - foreach ($this->documentsIterator($collection['$id']) as $document) { - go(function (Document $document, callable $callback) { - if (empty($document->getId()) || empty($document->getCollection())) { - return; - } - - $old = $document->getArrayCopy(); - $new = call_user_func($callback, $document); - - if (is_null($new) || $new->getArrayCopy() == $old) { - return; - } - - try { - $this->projectDB->updateDocument($document->getCollection(), $document->getId(), $document); - } catch (\Throwable $th) { - Console::error('Failed to update document: ' . $th->getMessage()); - return; - } - }, $document, $callback); - } - }, $collection, $callback); + foreach ($this->documentsIterator($collection['$id']) as $document) { + go(function (Document $document, callable $callback) { + if (empty($document->getId()) || empty($document->getCollection())) { + return; + } + + $old = $document->getArrayCopy(); + $new = call_user_func($callback, $document); + + if (is_null($new) || $new->getArrayCopy() == $old) { + return; + } + + try { + $this->projectDB->updateDocument($document->getCollection(), $document->getId(), $document); + } catch (\Throwable $th) { + Console::error('Failed to update document: ' . $th->getMessage()); + return; + } + }, $document, $callback); + } } } diff --git a/src/Appwrite/Migration/Version/V19.php b/src/Appwrite/Migration/Version/V19.php index bb887e40f74..18234ebdc44 100644 --- a/src/Appwrite/Migration/Version/V19.php +++ b/src/Appwrite/Migration/Version/V19.php @@ -816,29 +816,27 @@ public function forEachDocument(callable $callback): void Console::log('Migrating Collection ' . $collection['$id'] . ':'); - \Co\run(function (array $collection, callable $callback) { - foreach ($this->documentsIterator($collection['$id']) as $document) { - go(function (Document $document, callable $callback) { - if (empty($document->getId()) || empty($document->getCollection())) { - return; - } + foreach ($this->documentsIterator($collection['$id']) as $document) { + go(function (Document $document, callable $callback) { + if (empty($document->getId()) || empty($document->getCollection())) { + return; + } - $old = $document->getArrayCopy(); - $new = call_user_func($callback, $document); + $old = $document->getArrayCopy(); + $new = call_user_func($callback, $document); - if (is_null($new) || $new->getArrayCopy() == $old) { - return; - } + if (is_null($new) || $new->getArrayCopy() == $old) { + return; + } - try { - $this->projectDB->updateDocument($document->getCollection(), $document->getId(), $document); - } catch (\Throwable $th) { - Console::error('Failed to update document: ' . $th->getMessage()); - return; - } - }, $document, $callback); - } - }, $collection, $callback); + try { + $this->projectDB->updateDocument($document->getCollection(), $document->getId(), $document); + } catch (\Throwable $th) { + Console::error('Failed to update document: ' . $th->getMessage()); + return; + } + }, $document, $callback); + } } } } diff --git a/src/Appwrite/Platform/Tasks/Migrate.php b/src/Appwrite/Platform/Tasks/Migrate.php index 4d921ff1375..e8d716a1f0d 100644 --- a/src/Appwrite/Platform/Tasks/Migrate.php +++ b/src/Appwrite/Platform/Tasks/Migrate.php @@ -33,8 +33,11 @@ public function __construct() ->inject('dbForConsole') ->inject('getProjectDB') ->inject('register') - ->callback(fn ($version, $dbForConsole, $getProjectDB, Registry $register) => $this->action($version, $dbForConsole, $getProjectDB, $register)); - + ->callback(function ($version, $dbForConsole, $getProjectDB, Registry $register) { + \Co\run(function () use ($version, $dbForConsole, $getProjectDB, $register) { + $this->action($version, $dbForConsole, $getProjectDB, $register); + }); + }); } private function clearProjectsCache(Document $project) @@ -50,16 +53,15 @@ private function clearProjectsCache(Document $project) } } } while ($iterator > 0); - } catch (\Throwable $th) { - Console::error('Failed to clear project ("'.$project->getId().'") cache with error: '.$th->getMessage()); + Console::error('Failed to clear project ("' . $project->getId() . '") cache with error: ' . $th->getMessage()); } } public function action(string $version, Database $dbForConsole, callable $getProjectDB, Registry $register) { Authorization::disable(); - if (! array_key_exists($version, Migration::$versions)) { + if (!array_key_exists($version, Migration::$versions)) { Console::error("Version {$version} not found."); Console::exit(1); @@ -77,7 +79,7 @@ public function action(string $version, Database $dbForConsole, callable $getPro $app = new App('UTC'); - Console::success('Starting Data Migration to version '.$version); + Console::success('Starting Data Migration to version ' . $version); $console = $app->getResource('console'); @@ -97,11 +99,11 @@ public function action(string $version, Database $dbForConsole, callable $getPro $totalProjects = $dbForConsole->count('projects') + 1; } - $class = 'Appwrite\\Migration\\Version\\'.Migration::$versions[$version]; + $class = 'Appwrite\\Migration\\Version\\' . Migration::$versions[$version]; /** @var Migration $migration */ $migration = new $class(); - while (! empty($projects)) { + while (!empty($projects)) { foreach ($projects as $project) { /** * Skip user projects with id 'console' @@ -122,7 +124,7 @@ public function action(string $version, Database $dbForConsole, callable $getPro ->setPDO($register->get('db', true)) ->execute(); } catch (\Throwable $th) { - Console::error('Failed to update project ("'.$project->getId().'") version with error: '.$th->getMessage()); + Console::error('Failed to update project ("' . $project->getId() . '") version with error: ' . $th->getMessage()); throw $th; } @@ -135,7 +137,7 @@ public function action(string $version, Database $dbForConsole, callable $getPro $offset = $offset + $limit; $count = $count + $sum; - Console::log('Migrated '.$count.'/'.$totalProjects.' projects...'); + Console::log('Migrated ' . $count . '/' . $totalProjects . ' projects...'); } Console::success('Data Migration Completed'); From 6a4fa91aaca5c5e6eb212b3d898fbb08d0bd0891 Mon Sep 17 00:00:00 2001 From: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com> Date: Thu, 8 Aug 2024 22:55:35 +0000 Subject: [PATCH 2/9] chore: bump executor version from 0.5.5 to 0.5.7 --- app/views/install/compose.phtml | 2 +- docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 374e20eb39d..39cc03c8a68 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -753,7 +753,7 @@ $image = $this->getParam('image', ''); <<: *x-logging restart: unless-stopped stop_signal: SIGINT - image: openruntimes/executor:0.5.5 + image: openruntimes/executor:0.5.7 networks: - appwrite - runtimes diff --git a/docker-compose.yml b/docker-compose.yml index be468259921..c17f81bddfc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -833,7 +833,7 @@ services: hostname: exc1 <<: *x-logging stop_signal: SIGINT - image: openruntimes/executor:0.5.5 + image: openruntimes/executor:0.5.7 restart: unless-stopped networks: - appwrite From 8eb707be2ceaf4aea702f01ce5b4295f58520872 Mon Sep 17 00:00:00 2001 From: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com> Date: Fri, 9 Aug 2024 15:53:26 +0000 Subject: [PATCH 3/9] Bump console to version 4.3.29 --- .gitmodules | 2 +- app/console | 2 +- app/init.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index e9d2cb296f3..d34931a83b8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "app/console"] path = app/console url = https://github.com/appwrite/console - branch = 4.3.27 + branch = 4.3.29 diff --git a/app/console b/app/console index e0828010f4c..48696c8f593 160000 --- a/app/console +++ b/app/console @@ -1 +1 @@ -Subproject commit e0828010f4c222bb99cf65ddfed288e60602666f +Subproject commit 48696c8f593cb01ccaaf63f88cc248520a54d6da diff --git a/app/init.php b/app/init.php index bef85ff1cc6..0c2316459c9 100644 --- a/app/init.php +++ b/app/init.php @@ -112,7 +112,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 = 4327; +const APP_CACHE_BUSTER = 4329; const APP_VERSION_STABLE = '1.5.8'; const APP_DATABASE_ATTRIBUTE_EMAIL = 'email'; const APP_DATABASE_ATTRIBUTE_ENUM = 'enum'; From 2b9f3c46382588f92b9a53faa03913812fd9dba7 Mon Sep 17 00:00:00 2001 From: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com> Date: Fri, 9 Aug 2024 15:57:07 +0000 Subject: [PATCH 4/9] Bump appwrite version to 1.5.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 eb22339ebcb..9376a768b4f 100644 --- a/README-CN.md +++ b/README-CN.md @@ -67,7 +67,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.5.8 + appwrite/appwrite:1.5.9 ``` ### Windows @@ -79,7 +79,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.5.8 + appwrite/appwrite:1.5.9 ``` #### PowerShell @@ -89,7 +89,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.5.8 + appwrite/appwrite:1.5.9 ``` 运行后,可以在浏览器上访问 http://localhost 找到 Appwrite 控制台。在非 Linux 的本机主机上完成安装后,服务器可能需要几分钟才能启动。 diff --git a/README.md b/README.md index c355674ea5f..0b731dcf307 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,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.5.8 + appwrite/appwrite:1.5.9 ``` ### Windows @@ -87,7 +87,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.5.8 + appwrite/appwrite:1.5.9 ``` #### PowerShell @@ -97,7 +97,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.5.8 + appwrite/appwrite:1.5.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 0c2316459c9..ef95ae4d11d 100644 --- a/app/init.php +++ b/app/init.php @@ -113,7 +113,7 @@ const APP_USER_ACCCESS = 24 * 60 * 60; // 24 hours const APP_CACHE_UPDATE = 24 * 60 * 60; // 24 hours const APP_CACHE_BUSTER = 4329; -const APP_VERSION_STABLE = '1.5.8'; +const APP_VERSION_STABLE = '1.5.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 539282387d3..7565dc167f1 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -87,6 +87,7 @@ abstract class Migration '1.5.6' => 'V20', '1.5.7' => 'V20', '1.5.8' => 'V20', + '1.5.9' => 'V20', ]; /** From 0a18f77e68fe2b74dd391f31187fc1158f6cd3be Mon Sep 17 00:00:00 2001 From: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com> Date: Fri, 9 Aug 2024 16:04:40 +0000 Subject: [PATCH 5/9] Add 1.5.9 to CHANGES.md --- CHANGES.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 4cf033308cc..85bd4d0c3bf 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,22 @@ +# Version 1.5.9 + +## What's Changed + +### Notable changes + +* Add Darija (Moroccan Arabic) translation file in [7501](https://github.com/appwrite/appwrite/pull/7501) +* Bump console to version 4.3.29 in [8504](https://github.com/appwrite/appwrite/pull/8504) + +### Fixes + +* Fix domain check in [8472](https://github.com/appwrite/appwrite/pull/8472) +* Fix "API must be called in the coroutine" in [8495](https://github.com/appwrite/appwrite/pull/8495) +* Bump executor version from 0.5.5 to 0.5.7 in [8502](https://github.com/appwrite/appwrite/pull/8502) + +### Miscellaneous +* Add profiler for debugging in [8397](https://github.com/appwrite/appwrite/pull/8397) +* Document APIs that don't support redirects in [8233](https://github.com/appwrite/appwrite/pull/8233) + # Version 1.5.8 ## What's Changed From a52626e5d31d99935a58e9763149a3c07dadd256 Mon Sep 17 00:00:00 2001 From: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:34:23 +0000 Subject: [PATCH 6/9] fix(upgrade): fix migration stuck at "Starting Data Migration [...]" The iterator was in the loop so it was always reset to null and the same data set to be scanned. For cases where this happened, the iterator was not empty, but the keys returned from the scan was empty. According to [redis](https://redis.io/docs/latest/commands/scan/#number-of-elements-returned-at-every-scan-call), this is expected behavior. > SCAN family functions do not guarantee that the number of elements returned per call are in a given range. The commands are also allowed to return zero elements, and the client should not consider the iteration complete as long as the returned cursor is not zero. As such, we must make sure we're using the new iterator returned to continue scanning the keys. --- src/Appwrite/Platform/Tasks/Migrate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Tasks/Migrate.php b/src/Appwrite/Platform/Tasks/Migrate.php index e8d716a1f0d..dcba59bb1dc 100644 --- a/src/Appwrite/Platform/Tasks/Migrate.php +++ b/src/Appwrite/Platform/Tasks/Migrate.php @@ -43,8 +43,8 @@ public function __construct() private function clearProjectsCache(Document $project) { try { + $iterator = null; do { - $iterator = null; $pattern = "default-cache-_{$project->getInternalId()}:*"; $keys = $this->redis->scan($iterator, $pattern, 1000); if ($keys !== false) { From 0d451ec123dc05c4ea908eb8d9de348b807cff5a Mon Sep 17 00:00:00 2001 From: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:44:55 +0000 Subject: [PATCH 7/9] Bump console to version 4.3.30 --- .gitmodules | 2 +- app/console | 2 +- app/init.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index d34931a83b8..a959e29c235 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "app/console"] path = app/console url = https://github.com/appwrite/console - branch = 4.3.29 + branch = 4.3.30 diff --git a/app/console b/app/console index 48696c8f593..0959b594b32 160000 --- a/app/console +++ b/app/console @@ -1 +1 @@ -Subproject commit 48696c8f593cb01ccaaf63f88cc248520a54d6da +Subproject commit 0959b594b32f176819d4afb3a769afea212db789 diff --git a/app/init.php b/app/init.php index ef95ae4d11d..b09670385ad 100644 --- a/app/init.php +++ b/app/init.php @@ -112,7 +112,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 = 4329; +const APP_CACHE_BUSTER = 4330; const APP_VERSION_STABLE = '1.5.9'; const APP_DATABASE_ATTRIBUTE_EMAIL = 'email'; const APP_DATABASE_ATTRIBUTE_ENUM = 'enum'; From f47af1626c46769d8af75381a7e6431db6f5f90f Mon Sep 17 00:00:00 2001 From: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:55:22 +0000 Subject: [PATCH 8/9] Bump appwrite version to 1.5.10 --- 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 9376a768b4f..5e0cbab4c4b 100644 --- a/README-CN.md +++ b/README-CN.md @@ -67,7 +67,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.5.9 + appwrite/appwrite:1.5.10 ``` ### Windows @@ -79,7 +79,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.5.9 + appwrite/appwrite:1.5.10 ``` #### PowerShell @@ -89,7 +89,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.5.9 + appwrite/appwrite:1.5.10 ``` 运行后,可以在浏览器上访问 http://localhost 找到 Appwrite 控制台。在非 Linux 的本机主机上完成安装后,服务器可能需要几分钟才能启动。 diff --git a/README.md b/README.md index 0b731dcf307..8305d78ef0c 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,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.5.9 + appwrite/appwrite:1.5.10 ``` ### Windows @@ -87,7 +87,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.5.9 + appwrite/appwrite:1.5.10 ``` #### PowerShell @@ -97,7 +97,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.5.9 + appwrite/appwrite:1.5.10 ``` 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 b09670385ad..3b43d988955 100644 --- a/app/init.php +++ b/app/init.php @@ -113,7 +113,7 @@ const APP_USER_ACCCESS = 24 * 60 * 60; // 24 hours const APP_CACHE_UPDATE = 24 * 60 * 60; // 24 hours const APP_CACHE_BUSTER = 4330; -const APP_VERSION_STABLE = '1.5.9'; +const APP_VERSION_STABLE = '1.5.10'; 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 7565dc167f1..d0bb80d6859 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -88,6 +88,7 @@ abstract class Migration '1.5.7' => 'V20', '1.5.8' => 'V20', '1.5.9' => 'V20', + '1.5.10' => 'V20', ]; /** From 92fea47bf4ca1fcda169887234e46730c22907c1 Mon Sep 17 00:00:00 2001 From: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:58:25 +0000 Subject: [PATCH 9/9] Add 1.5.10 to CHANGES.md --- CHANGES.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 85bd4d0c3bf..e6649d795eb 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,15 @@ +# Version 1.5.10 + +## What's Changed + +### Notable changes + +* Bump console to version 4.3.30 in [#8520](https://github.com/appwrite/appwrite/pull/8520) + +### Fixes + +* Fix migration stuck at "Starting Data Migration [...]" in [#8519](https://github.com/appwrite/appwrite/pull/8519) + # Version 1.5.9 ## What's Changed