From c2f994a02ee8fef2350d151d0ac9747886966bbd Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Mon, 1 Nov 2021 20:47:07 -0400 Subject: [PATCH 1/5] Pass filters to createAttribute to inherit default value defined in this layer --- app/controllers/api/database.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index 65af782193..a51afa7f1a 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -94,6 +94,7 @@ function createAttribute($collectionId, $attribute, $response, $dbForInternal, $ 'array' => $array, 'format' => $format, 'formatOptions' => $formatOptions, + 'filters' => $filters, ]); $dbForInternal->checkAttribute($collection, $attribute); From 7624f97f0b0d8d8b3f9e91ddc68da9ad36541add Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Mon, 1 Nov 2021 20:48:14 -0400 Subject: [PATCH 2/5] PHP_FLOAT_MIN provides the smallest positive float, not largest negative --- app/controllers/api/database.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index a51afa7f1a..0fc05c8cf5 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -994,7 +994,7 @@ App::post('/v1/database/collections/:collectionId/attributes/float') /** @var Appwrite\Stats\Stats $usage */ // Ensure attribute default is within range - $min = (is_null($min)) ? PHP_FLOAT_MIN : \floatval($min); + $min = (is_null($min)) ? -PHP_FLOAT_MAX : \floatval($min); $max = (is_null($max)) ? PHP_FLOAT_MAX : \floatval($max); if ($min > $max) { From dd5c873b99b8a57f6999b84e1dbaf9019dac38f3 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Mon, 1 Nov 2021 20:48:38 -0400 Subject: [PATCH 3/5] Clear external cache when resources are deleted --- app/controllers/api/database.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index 0fc05c8cf5..6a266f177f 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -644,6 +644,8 @@ App::delete('/v1/database/collections/:collectionId') throw new Exception('Failed to remove collection from DB', 500); } + $dbForExternal->deleteCachedCollection($collection->getId()); + $deletes ->setParam('type', DELETE_TYPE_DOCUMENT) ->setParam('document', $collection) @@ -2005,6 +2007,7 @@ App::delete('/v1/database/collections/:collectionId/documents/:documentId') } $dbForExternal->deleteDocument($collectionId, $documentId); + $dbForExternal->deleteCachedDocument($collectionId, $documentId); $usage ->setParam('database.documents.delete', 1) From b9bf29b559c014ddc490e7891ec35be9407baa22 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Mon, 1 Nov 2021 20:49:35 -0400 Subject: [PATCH 4/5] Test patch for optional array attributes --- composer.json | 2 +- composer.lock | 65 +++++++++++++++++++++++++++++---------------------- 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/composer.json b/composer.json index 8b0d69f1fe..424a79edcf 100644 --- a/composer.json +++ b/composer.json @@ -45,7 +45,7 @@ "utopia-php/cache": "0.4.*", "utopia-php/cli": "0.11.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "0.10.*", + "utopia-php/database": "dev-feat-null-valid-for-optional-array-attributes as 0.10.1", "utopia-php/locale": "0.4.*", "utopia-php/orchestration": "0.2.*", "utopia-php/registry": "0.5.*", diff --git a/composer.lock b/composer.lock index 9ad7258756..20505fd672 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": "fa378feaffc446f557a140035a1c77b6", + "content-hash": "4f414d29fd0c3d0f123bf2d74a4fa195", "packages": [ { "name": "adhocore/jwt", @@ -2138,16 +2138,16 @@ }, { "name": "utopia-php/database", - "version": "0.10.0", + "version": "dev-feat-null-valid-for-optional-array-attributes", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "b7c60b0ec769a9050dd2b939b78ff1f5d4fa27e8" + "reference": "9d5d60bfc00bf4229807f58714063d07a45b59f1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/b7c60b0ec769a9050dd2b939b78ff1f5d4fa27e8", - "reference": "b7c60b0ec769a9050dd2b939b78ff1f5d4fa27e8", + "url": "https://api.github.com/repos/utopia-php/database/zipball/9d5d60bfc00bf4229807f58714063d07a45b59f1", + "reference": "9d5d60bfc00bf4229807f58714063d07a45b59f1", "shasum": "" }, "require": { @@ -2195,9 +2195,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.10.0" + "source": "https://github.com/utopia-php/database/tree/feat-null-valid-for-optional-array-attributes" }, - "time": "2021-10-04T17:23:25+00:00" + "time": "2021-11-02T00:29:45+00:00" }, { "name": "utopia-php/domains", @@ -4103,23 +4103,23 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.7", + "version": "9.2.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "d4c798ed8d51506800b441f7a13ecb0f76f12218" + "reference": "cf04e88a2e3c56fc1a65488afd493325b4c1bc3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/d4c798ed8d51506800b441f7a13ecb0f76f12218", - "reference": "d4c798ed8d51506800b441f7a13ecb0f76f12218", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/cf04e88a2e3c56fc1a65488afd493325b4c1bc3e", + "reference": "cf04e88a2e3c56fc1a65488afd493325b4c1bc3e", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.12.0", + "nikic/php-parser": "^4.13.0", "php": ">=7.3", "phpunit/php-file-iterator": "^3.0.3", "phpunit/php-text-template": "^2.0.2", @@ -4168,7 +4168,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.7" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.8" }, "funding": [ { @@ -4176,7 +4176,7 @@ "type": "github" } ], - "time": "2021-09-17T05:39:03+00:00" + "time": "2021-10-30T08:01:38+00:00" }, { "name": "phpunit/php-file-iterator", @@ -5588,16 +5588,16 @@ }, { "name": "symfony/console", - "version": "v5.3.7", + "version": "v5.3.10", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "8b1008344647462ae6ec57559da166c2bfa5e16a" + "reference": "d4e409d9fbcfbf71af0e5a940abb7b0b4bad0bd3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/8b1008344647462ae6ec57559da166c2bfa5e16a", - "reference": "8b1008344647462ae6ec57559da166c2bfa5e16a", + "url": "https://api.github.com/repos/symfony/console/zipball/d4e409d9fbcfbf71af0e5a940abb7b0b4bad0bd3", + "reference": "d4e409d9fbcfbf71af0e5a940abb7b0b4bad0bd3", "shasum": "" }, "require": { @@ -5667,7 +5667,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.3.7" + "source": "https://github.com/symfony/console/tree/v5.3.10" }, "funding": [ { @@ -5683,7 +5683,7 @@ "type": "tidelift" } ], - "time": "2021-08-25T20:02:16+00:00" + "time": "2021-10-26T09:30:15+00:00" }, { "name": "symfony/polyfill-intl-grapheme", @@ -6090,16 +6090,16 @@ }, { "name": "symfony/string", - "version": "v5.3.7", + "version": "v5.3.10", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "8d224396e28d30f81969f083a58763b8b9ceb0a5" + "reference": "d70c35bb20bbca71fc4ab7921e3c6bda1a82a60c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/8d224396e28d30f81969f083a58763b8b9ceb0a5", - "reference": "8d224396e28d30f81969f083a58763b8b9ceb0a5", + "url": "https://api.github.com/repos/symfony/string/zipball/d70c35bb20bbca71fc4ab7921e3c6bda1a82a60c", + "reference": "d70c35bb20bbca71fc4ab7921e3c6bda1a82a60c", "shasum": "" }, "require": { @@ -6153,7 +6153,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.3.7" + "source": "https://github.com/symfony/string/tree/v5.3.10" }, "funding": [ { @@ -6169,7 +6169,7 @@ "type": "tidelift" } ], - "time": "2021-08-26T08:00:08+00:00" + "time": "2021-10-27T18:21:46+00:00" }, { "name": "textalk/websocket", @@ -6505,9 +6505,18 @@ "time": "2015-12-17T08:42:14+00:00" } ], - "aliases": [], + "aliases": [ + { + "package": "utopia-php/database", + "version": "dev-feat-null-valid-for-optional-array-attributes", + "alias": "0.10.1", + "alias_normalized": "0.10.1.0" + } + ], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "utopia-php/database": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { From f474de4b7f26de41659ff1ddbe685bacc1173923 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Tue, 2 Nov 2021 11:19:20 -0400 Subject: [PATCH 5/5] Use database release for optional array attributes --- composer.json | 2 +- composer.lock | 40 +++++++++++++++------------------------- 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/composer.json b/composer.json index 424a79edcf..8b0d69f1fe 100644 --- a/composer.json +++ b/composer.json @@ -45,7 +45,7 @@ "utopia-php/cache": "0.4.*", "utopia-php/cli": "0.11.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "dev-feat-null-valid-for-optional-array-attributes as 0.10.1", + "utopia-php/database": "0.10.*", "utopia-php/locale": "0.4.*", "utopia-php/orchestration": "0.2.*", "utopia-php/registry": "0.5.*", diff --git a/composer.lock b/composer.lock index 20505fd672..4fcf643c3d 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": "4f414d29fd0c3d0f123bf2d74a4fa195", + "content-hash": "fa378feaffc446f557a140035a1c77b6", "packages": [ { "name": "adhocore/jwt", @@ -2138,16 +2138,16 @@ }, { "name": "utopia-php/database", - "version": "dev-feat-null-valid-for-optional-array-attributes", + "version": "0.10.1", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "9d5d60bfc00bf4229807f58714063d07a45b59f1" + "reference": "9b4697612a2cd1ad55beeb6a02570f6ffe26dc1e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/9d5d60bfc00bf4229807f58714063d07a45b59f1", - "reference": "9d5d60bfc00bf4229807f58714063d07a45b59f1", + "url": "https://api.github.com/repos/utopia-php/database/zipball/9b4697612a2cd1ad55beeb6a02570f6ffe26dc1e", + "reference": "9b4697612a2cd1ad55beeb6a02570f6ffe26dc1e", "shasum": "" }, "require": { @@ -2195,9 +2195,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/feat-null-valid-for-optional-array-attributes" + "source": "https://github.com/utopia-php/database/tree/0.10.1" }, - "time": "2021-11-02T00:29:45+00:00" + "time": "2021-11-02T15:10:39+00:00" }, { "name": "utopia-php/domains", @@ -2304,20 +2304,19 @@ }, { "name": "utopia-php/image", - "version": "0.5.2", + "version": "0.5.3", "source": { "type": "git", "url": "https://github.com/utopia-php/image.git", - "reference": "049446fea7cb53db8a431455ec382e30e6d1482a" + "reference": "4a8429b62dcf56562b038d6712375f75166f0c02" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/image/zipball/049446fea7cb53db8a431455ec382e30e6d1482a", - "reference": "049446fea7cb53db8a431455ec382e30e6d1482a", + "url": "https://api.github.com/repos/utopia-php/image/zipball/4a8429b62dcf56562b038d6712375f75166f0c02", + "reference": "4a8429b62dcf56562b038d6712375f75166f0c02", "shasum": "" }, "require": { - "chillerlan/php-qrcode": "4.3.1", "ext-imagick": "*", "php": ">=7.4" }, @@ -2351,9 +2350,9 @@ ], "support": { "issues": "https://github.com/utopia-php/image/issues", - "source": "https://github.com/utopia-php/image/tree/0.5.2" + "source": "https://github.com/utopia-php/image/tree/0.5.3" }, - "time": "2021-10-18T06:41:05+00:00" + "time": "2021-11-02T05:47:16+00:00" }, { "name": "utopia-php/locale", @@ -6505,18 +6504,9 @@ "time": "2015-12-17T08:42:14+00:00" } ], - "aliases": [ - { - "package": "utopia-php/database", - "version": "dev-feat-null-valid-for-optional-array-attributes", - "alias": "0.10.1", - "alias_normalized": "0.10.1.0" - } - ], + "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "utopia-php/database": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": {