From 13c9f79b3dfcd375307f7a86f0743d60409aca43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 28 Apr 2025 08:38:49 +0200 Subject: [PATCH 1/9] Update console --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 75e544a91b..acdec401cc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -213,7 +213,7 @@ services: appwrite-console: <<: *x-logging container_name: appwrite-console - image: appwrite/console:5.3.0-sites-rc.40 + image: appwrite/console:5.3.0-sites-rc.42 restart: unless-stopped networks: - appwrite From 08806afb38fd83605b760f267fee4d0fa8d5c65b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 28 Apr 2025 08:39:33 +0200 Subject: [PATCH 2/9] Fix CSV import bug --- .../Modules/Storage/Http/Tokens/Buckets/Files/XList.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Modules/Storage/Http/Tokens/Buckets/Files/XList.php b/src/Appwrite/Platform/Modules/Storage/Http/Tokens/Buckets/Files/XList.php index a9d1ba1f49..e3e571ae32 100644 --- a/src/Appwrite/Platform/Modules/Storage/Http/Tokens/Buckets/Files/XList.php +++ b/src/Appwrite/Platform/Modules/Storage/Http/Tokens/Buckets/Files/XList.php @@ -64,7 +64,7 @@ class XList extends Action $queries = Query::parseQueries($queries); $queries[] = Query::equal('resourceType', ["files"]); - $queries[] = Query::equal('resourceId', [$bucket->getInternalId() . ':' . $file->getInternalId()]); + $queries[] = Query::equal('resourceInternalId', [$bucket->getInternalId() . ':' . $file->getInternalId()]); // Get cursor document if there was a cursor query $cursor = \array_filter($queries, function ($query) { return \in_array($query->getMethod(), [Query::TYPE_CURSOR_AFTER, Query::TYPE_CURSOR_BEFORE]); From 841d260b5fd31fe3c776a06e1c12e872d3b70992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 29 Apr 2025 11:31:06 +0200 Subject: [PATCH 3/9] PlatformDB migration preparations --- app/config/collections/platform.php | 2 +- app/controllers/general.php | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/config/collections/platform.php b/app/config/collections/platform.php index ce8be6a874..e53194c513 100644 --- a/app/config/collections/platform.php +++ b/app/config/collections/platform.php @@ -1148,7 +1148,7 @@ return [ 'format' => '', 'size' => 32, 'signed' => true, - 'required' => true, + 'required' => false, 'default' => null, 'array' => false, 'filters' => [], diff --git a/app/controllers/general.php b/app/controllers/general.php index 889571fe62..939573261e 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -149,7 +149,17 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw $dbForProject = $getProjectDB($project); /** @var Document $deployment */ - $deployment = Authorization::skip(fn () => $dbForProject->getDocument('deployments', $rule->getAttribute('deploymentId'))); + if(!empty($rule->getAttribute('deploymentId', ''))) { + $deployment = Authorization::skip(fn () => $dbForProject->getDocument('deployments', $rule->getAttribute('deploymentId'))); + } else { + // 1.6.x DB schema compatibility + // TODO: Make sure deploymentId is never empty, and remove this code + $resource = $rule->getAttribute('deploymentResourceType', '') === 'function' ? + Authorization::skip(fn () => $dbForProject->getDocument('functions', $rule->getAttribute('deploymentResourceId', ''))) : + Authorization::skip(fn () => $dbForProject->getDocument('sites', $rule->getAttribute('deploymentResourceId', ''))); + $deploymentId = $resource->getAttribute('deploymentId', $resource->getAttribute('deployment', '')); + $deployment = Authorization::skip(fn () => $dbForProject->getDocument('deployments', $deploymentId)); + } if ($deployment->getAttribute('resourceType', '') === 'functions') { $type = 'function'; From 7ece755abf4b5341db8fb6d721e40c1b7e9a3e4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 29 Apr 2025 11:56:51 +0200 Subject: [PATCH 4/9] Improve code quality --- app/controllers/general.php | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index 939573261e..dbc07f950b 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -149,17 +149,31 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw $dbForProject = $getProjectDB($project); /** @var Document $deployment */ - if(!empty($rule->getAttribute('deploymentId', ''))) { - $deployment = Authorization::skip(fn () => $dbForProject->getDocument('deployments', $rule->getAttribute('deploymentId'))); + if (!empty($rule->getAttribute('deploymentId', ''))) { + $deployment = Authorization::skip(fn () => $dbForProject->getDocument('deployments', $rule->getAttribute('deploymentId'))); } else { // 1.6.x DB schema compatibility // TODO: Make sure deploymentId is never empty, and remove this code - $resource = $rule->getAttribute('deploymentResourceType', '') === 'function' ? - Authorization::skip(fn () => $dbForProject->getDocument('functions', $rule->getAttribute('deploymentResourceId', ''))) : - Authorization::skip(fn () => $dbForProject->getDocument('sites', $rule->getAttribute('deploymentResourceId', ''))); - $deploymentId = $resource->getAttribute('deploymentId', $resource->getAttribute('deployment', '')); - $deployment = Authorization::skip(fn () => $dbForProject->getDocument('deployments', $deploymentId)); - } + + // Check if site or function; should never be site, but better safe than sorry + // Attempts to use attribute from both schemas (1.6 and 1.7) + $resourceType = $rule->getAttribute('deploymentResourceType', $rule->getAttribute('resourceType', '')); + + // ID of site or function + $resourceId = $rule->getAttribute('deploymentResourceId', ''); + + // Document of site or function + $resource = $resourceType === 'function' ? + Authorization::skip(fn () => $dbForProject->getDocument('functions', $resourceId)) : + Authorization::skip(fn () => $dbForProject->getDocument('sites', $resourceId)); + + // ID of active deployments + // Attempts to use attribute from both schemas (1.6 and 1.7) + $activeDeploymentId = $resource->getAttribute('deploymentId', $resource->getAttribute('deployment', '')); + + // Get deployment document, as intended originally + $deployment = Authorization::skip(fn () => $dbForProject->getDocument('deployments', $activeDeploymentId)); + } if ($deployment->getAttribute('resourceType', '') === 'functions') { $type = 'function'; From 0148c3ed7780fd1fe6d9e6632bf74732f4026deb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 29 Apr 2025 16:00:09 +0200 Subject: [PATCH 5/9] Fix migration row length issue --- app/config/collections/projects.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/config/collections/projects.php b/app/config/collections/projects.php index 19547559e6..ec44e0a72b 100644 --- a/app/config/collections/projects.php +++ b/app/config/collections/projects.php @@ -1361,7 +1361,7 @@ return [ '$id' => ID::custom('sourcePath'), 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 2048, + 'size' => 16384, 'signed' => true, 'required' => false, 'default' => null, From bd50baff85f85a0746d2da7274450a2d41559144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 30 Apr 2025 09:31:17 +0200 Subject: [PATCH 6/9] Upgrade db lib for migration fix --- composer.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/composer.lock b/composer.lock index 17b3b27078..a1b91ab2e6 100644 --- a/composer.lock +++ b/composer.lock @@ -3705,16 +3705,16 @@ }, { "name": "utopia-php/fetch", - "version": "0.4.1", + "version": "0.4.2", "source": { "type": "git", "url": "https://github.com/utopia-php/fetch.git", - "reference": "65095dac14037db0c822fb5e209e5bd3187a0303" + "reference": "83986d1be75a2fae4e684107fe70dd78a8e19b77" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/fetch/zipball/65095dac14037db0c822fb5e209e5bd3187a0303", - "reference": "65095dac14037db0c822fb5e209e5bd3187a0303", + "url": "https://api.github.com/repos/utopia-php/fetch/zipball/83986d1be75a2fae4e684107fe70dd78a8e19b77", + "reference": "83986d1be75a2fae4e684107fe70dd78a8e19b77", "shasum": "" }, "require": { @@ -3738,9 +3738,9 @@ "description": "A simple library that provides an interface for making HTTP Requests.", "support": { "issues": "https://github.com/utopia-php/fetch/issues", - "source": "https://github.com/utopia-php/fetch/tree/0.4.1" + "source": "https://github.com/utopia-php/fetch/tree/0.4.2" }, - "time": "2025-04-14T07:34:27+00:00" + "time": "2025-04-25T13:48:02+00:00" }, { "name": "utopia-php/framework", @@ -5275,16 +5275,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.13.0", + "version": "1.13.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "024473a478be9df5fdaca2c793f2232fe788e414" + "reference": "1720ddd719e16cf0db4eb1c6eca108031636d46c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/024473a478be9df5fdaca2c793f2232fe788e414", - "reference": "024473a478be9df5fdaca2c793f2232fe788e414", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/1720ddd719e16cf0db4eb1c6eca108031636d46c", + "reference": "1720ddd719e16cf0db4eb1c6eca108031636d46c", "shasum": "" }, "require": { @@ -5323,7 +5323,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.13.0" + "source": "https://github.com/myclabs/DeepCopy/tree/1.13.1" }, "funding": [ { @@ -5331,7 +5331,7 @@ "type": "tidelift" } ], - "time": "2025-02-12T12:17:51+00:00" + "time": "2025-04-29T12:36:36+00:00" }, { "name": "nikic/php-parser", From e1dbf2170e2ee79c23d52ff0ff7ff27535e40f28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 30 Apr 2025 12:10:51 +0200 Subject: [PATCH 7/9] Migration preparations --- app/config/collections/projects.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/config/collections/projects.php b/app/config/collections/projects.php index ec44e0a72b..152c6a5e6a 100644 --- a/app/config/collections/projects.php +++ b/app/config/collections/projects.php @@ -1699,7 +1699,7 @@ return [ 'format' => '', 'size' => 16, 'signed' => true, - 'required' => true, + 'required' => false, 'default' => 'waiting', 'array' => false, 'filters' => [], From 279ff8f5ae22302644a28305dabe23b92a0c16dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 30 Apr 2025 12:38:32 +0200 Subject: [PATCH 8/9] Migration preps, table width issues --- app/config/collections/projects.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/config/collections/projects.php b/app/config/collections/projects.php index 152c6a5e6a..99707752bb 100644 --- a/app/config/collections/projects.php +++ b/app/config/collections/projects.php @@ -1029,7 +1029,7 @@ return [ '$id' => ID::custom('fallbackFile'), 'type' => Database::VAR_STRING, 'format' => '', - 'size' => Database::LENGTH_KEY, + 'size' => 16384, 'signed' => true, 'required' => false, 'default' => null, @@ -1205,7 +1205,7 @@ return [ '$id' => ID::custom('adapter'), // ssr or static; named this way as it's a term in SSR frameworks 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 128, + 'size' => 16, 'signed' => true, 'required' => false, 'default' => '', @@ -1708,7 +1708,7 @@ return [ '$id' => ID::custom('buildPath'), 'type' => Database::VAR_STRING, 'format' => '', - 'size' => Database::LENGTH_KEY, + 'size' => 16384, 'signed' => true, 'required' => false, 'default' => '', @@ -1730,7 +1730,7 @@ return [ '$id' => ID::custom('adapter'), // ssr or static; named this way as it's a term in SSR frameworks 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 128, + 'size' => 16, 'signed' => true, 'required' => false, 'default' => '', @@ -1741,7 +1741,7 @@ return [ '$id' => ID::custom('fallbackFile'), 'type' => Database::VAR_STRING, 'format' => '', - 'size' => Database::LENGTH_KEY, + 'size' => 16384, 'signed' => true, 'required' => false, 'default' => null, From f76aff19163ecff093507cb5026b96ceff303622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Fri, 2 May 2025 11:17:51 +0200 Subject: [PATCH 9/9] Migration preparations --- app/config/collections/projects.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/config/collections/projects.php b/app/config/collections/projects.php index 99707752bb..5105304599 100644 --- a/app/config/collections/projects.php +++ b/app/config/collections/projects.php @@ -1372,7 +1372,7 @@ return [ '$id' => ID::custom('type'), 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 32, + 'size' => 2048, 'signed' => true, 'required' => true, 'default' => null,