From 94e330149f3e9ed1a8865aee99db1bc75a2728e4 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Wed, 4 Aug 2021 17:04:48 -0400 Subject: [PATCH 01/13] Catch limit exception on attributes --- app/controllers/api/database.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index 7df3172484..580dc951d4 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -89,6 +89,8 @@ $attributesCallback = function ($collectionId, $attribute, $response, $dbForInte ])); } catch (DuplicateException $th) { throw new Exception('Attribute already exists', 409); + } catch (LimitException $e) { + throw new Exception($e->getMessage(), 400); } $dbForInternal->purgeDocument('collections', $collectionId); From 4f4db30a8a9a34a844f76050aa6603e20dc15b19 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Wed, 4 Aug 2021 17:05:09 -0400 Subject: [PATCH 02/13] Test for attribute limit exception --- .../Database/DatabaseCustomServerTest.php | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tests/e2e/Services/Database/DatabaseCustomServerTest.php b/tests/e2e/Services/Database/DatabaseCustomServerTest.php index e5a75fa685..ca869f79d3 100644 --- a/tests/e2e/Services/Database/DatabaseCustomServerTest.php +++ b/tests/e2e/Services/Database/DatabaseCustomServerTest.php @@ -307,6 +307,54 @@ class DatabaseCustomServerTest extends Scope $this->assertEquals($response['headers']['status-code'], 404); } + /** + * @depends testDeleteCollection + */ + public function testAttributeCountLimit() + { + $collection = $this->client->call(Client::METHOD_POST, '/database/collections', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'name' => 'attributeCountLimit', + 'read' => ['role:all'], + 'write' => ['role:all'], + 'permission' => 'document', + ]); + + $collectionId = $collection['body']['$id']; + + // load the collection up to the limit + for ($i=0; $i < 1012; $i++) { + $attribute = $this->client->call(Client::METHOD_POST, '/database/collections/' . $collectionId . '/attributes/integer', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'attributeId' => "attribute{$i}", + 'required' => false, + ]); + + $this->assertEquals(201, $attribute['headers']['status-code']); + } + + sleep(20); + + $tooMany = $this->client->call(Client::METHOD_POST, '/database/collections/' . $collectionId . '/attributes/integer', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'attributeId' => "tooMany", + 'required' => false, + ]); + + $this->assertEquals(400, $tooMany['headers']['status-code']); + $this->assertEquals('Column limit reached. Cannot create new attribute.', $tooMany['body']['message']); + } + + public function testIndexLimitException() { $collection = $this->client->call(Client::METHOD_POST, '/database/collections', array_merge([ From 42ca474731baade1528d4dd600b2c37bde5f9da6 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Tue, 24 Aug 2021 20:01:11 -0400 Subject: [PATCH 03/13] Search for attributes from internal table --- app/controllers/api/database.php | 11 +++++++++++ .../Services/Database/DatabaseCustomServerTest.php | 7 ++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index 580dc951d4..609ffc7aab 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -56,6 +56,17 @@ $attributesCallback = function ($collectionId, $attribute, $response, $dbForInte throw new Exception('Collection not found', 404); } + $count = $dbForInternal->count('attributes', [ + new Query('collectionId', Query::TYPE_EQUAL, [$collectionId]) + ], 1012); + + // 1017 limit minus default attributes and one buffer for virtual columns + $limit = 1017 - MariaDB::getNumberOfDefaultAttributes() - 1; + + if ($count >= $limit) { + throw new Exception('Attribute limit exceeded', 400); + } + // TODO@kodumbeats how to depend on $size for Text validator length // Ensure attribute default is within required size if ($size > 0 && !\is_null($default)) { diff --git a/tests/e2e/Services/Database/DatabaseCustomServerTest.php b/tests/e2e/Services/Database/DatabaseCustomServerTest.php index ca869f79d3..3884ca7a3d 100644 --- a/tests/e2e/Services/Database/DatabaseCustomServerTest.php +++ b/tests/e2e/Services/Database/DatabaseCustomServerTest.php @@ -307,9 +307,6 @@ class DatabaseCustomServerTest extends Scope $this->assertEquals($response['headers']['status-code'], 404); } - /** - * @depends testDeleteCollection - */ public function testAttributeCountLimit() { $collection = $this->client->call(Client::METHOD_POST, '/database/collections', array_merge([ @@ -317,6 +314,7 @@ class DatabaseCustomServerTest extends Scope 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-key' => $this->getProject()['apiKey'] ]), [ + 'collectionId' => 'unique()', 'name' => 'attributeCountLimit', 'read' => ['role:all'], 'write' => ['role:all'], @@ -351,10 +349,9 @@ class DatabaseCustomServerTest extends Scope ]); $this->assertEquals(400, $tooMany['headers']['status-code']); - $this->assertEquals('Column limit reached. Cannot create new attribute.', $tooMany['body']['message']); + $this->assertEquals('Attribute limit exceeded', $tooMany['body']['message']); } - public function testIndexLimitException() { $collection = $this->client->call(Client::METHOD_POST, '/database/collections', array_merge([ From 8f066259801f8c36ff8471e0b49c93e59a5a4490 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Tue, 31 Aug 2021 11:53:20 -0400 Subject: [PATCH 04/13] Reduce sleep time in test --- tests/e2e/Services/Database/DatabaseCustomServerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/Services/Database/DatabaseCustomServerTest.php b/tests/e2e/Services/Database/DatabaseCustomServerTest.php index 3884ca7a3d..97b12aa279 100644 --- a/tests/e2e/Services/Database/DatabaseCustomServerTest.php +++ b/tests/e2e/Services/Database/DatabaseCustomServerTest.php @@ -337,7 +337,7 @@ class DatabaseCustomServerTest extends Scope $this->assertEquals(201, $attribute['headers']['status-code']); } - sleep(20); + sleep(5); $tooMany = $this->client->call(Client::METHOD_POST, '/database/collections/' . $collectionId . '/attributes/integer', array_merge([ 'content-type' => 'application/json', From efa0b8629926520ba798a2380b8a20ecdf6d5faf Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Tue, 31 Aug 2021 12:35:03 -0400 Subject: [PATCH 05/13] Add assertions for row width limit --- .../Database/DatabaseCustomServerTest.php | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/e2e/Services/Database/DatabaseCustomServerTest.php b/tests/e2e/Services/Database/DatabaseCustomServerTest.php index 97b12aa279..2be62f8fa8 100644 --- a/tests/e2e/Services/Database/DatabaseCustomServerTest.php +++ b/tests/e2e/Services/Database/DatabaseCustomServerTest.php @@ -352,6 +352,56 @@ class DatabaseCustomServerTest extends Scope $this->assertEquals('Attribute limit exceeded', $tooMany['body']['message']); } + public function testAttributeRowWidthLimit() + { + $collection = $this->client->call(Client::METHOD_POST, '/database/collections', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'collectionId' => 'attributeRowWidthLimit', + 'name' => 'attributeRowWidthLimit', + 'read' => ['role:all'], + 'write' => ['role:all'], + 'permission' => 'document', + ]); + + $this->assertEquals($collection['headers']['status-code'], 201); + $this->assertEquals($collection['body']['name'], 'attributeRowWidthLimit'); + + $collectionId = $collection['body']['$id']; + + // Add wide string attributes to approach row width limit + for ($i=0; $i < 15; $i++) { + $attribute = $this->client->call(Client::METHOD_POST, '/database/collections/' . $collectionId . '/attributes/string', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'attributeId' => "attribute{$i}", + 'size' => 1024, + 'required' => true, + ]); + + $this->assertEquals($attribute['headers']['status-code'], 201); + } + + sleep(5); + + $tooWide = $this->client->call(Client::METHOD_POST, '/database/collections/' . $collectionId . '/attributes/string', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'attributeId' => 'tooWide', + 'size' => 1024, + 'required' => true, + ]); + + // $this->assertEquals(400, $tooWide['headers']['status-code']); + // $this->assertEquals('Attribute limit exceeded', $tooWide['body']['message']); + } + public function testIndexLimitException() { $collection = $this->client->call(Client::METHOD_POST, '/database/collections', array_merge([ From e2d1b2df58a74b2a3e4c3e51d91ea9ea991ba831 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Tue, 31 Aug 2021 21:13:36 -0400 Subject: [PATCH 06/13] Fetch new checkAttribute database method --- composer.json | 2 +- composer.lock | 46 +++++++++++++++++++++++----------------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/composer.json b/composer.json index d48d2378aa..9bd152fb92 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-adjusted-query-validator as 0.10.0", + "utopia-php/database": "dev-feat-check-attribute-method as 0.10.0", "utopia-php/locale": "0.4.*", "utopia-php/registry": "0.5.*", "utopia-php/preloader": "0.2.*", diff --git a/composer.lock b/composer.lock index a5f2a3e062..829e348201 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": "175f077512c575216c4c88f1d33c6d00", + "content-hash": "9a7739aabd503572b8010be91192b144", "packages": [ { "name": "adhocore/jwt", @@ -355,16 +355,16 @@ }, { "name": "composer/package-versions-deprecated", - "version": "1.11.99.2", + "version": "1.11.99.3", "source": { "type": "git", "url": "https://github.com/composer/package-versions-deprecated.git", - "reference": "c6522afe5540d5fc46675043d3ed5a45a740b27c" + "reference": "fff576ac850c045158a250e7e27666e146e78d18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/c6522afe5540d5fc46675043d3ed5a45a740b27c", - "reference": "c6522afe5540d5fc46675043d3ed5a45a740b27c", + "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/fff576ac850c045158a250e7e27666e146e78d18", + "reference": "fff576ac850c045158a250e7e27666e146e78d18", "shasum": "" }, "require": { @@ -408,7 +408,7 @@ "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", "support": { "issues": "https://github.com/composer/package-versions-deprecated/issues", - "source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.2" + "source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.3" }, "funding": [ { @@ -424,7 +424,7 @@ "type": "tidelift" } ], - "time": "2021-05-24T07:46:03+00:00" + "time": "2021-08-17T13:49:14+00:00" }, { "name": "dragonmantank/cron-expression", @@ -1984,11 +1984,11 @@ }, { "name": "utopia-php/database", - "version": "dev-feat-adjusted-query-validator", + "version": "dev-feat-check-attribute-method", "source": { "type": "git", "url": "https://github.com/utopia-php/database", - "reference": "cb73391371f70ddb54bc0000064b15c5f173cb7a" + "reference": "2d1f48345f1284876f6847599c66eee145b7233e" }, "require": { "ext-mongodb": "*", @@ -2037,7 +2037,7 @@ "upf", "utopia" ], - "time": "2021-08-23T14:18:47+00:00" + "time": "2021-09-01T00:50:12+00:00" }, { "name": "utopia-php/domains", @@ -5313,16 +5313,16 @@ }, { "name": "symfony/console", - "version": "v5.3.6", + "version": "v5.3.7", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "51b71afd6d2dc8f5063199357b9880cea8d8bfe2" + "reference": "8b1008344647462ae6ec57559da166c2bfa5e16a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/51b71afd6d2dc8f5063199357b9880cea8d8bfe2", - "reference": "51b71afd6d2dc8f5063199357b9880cea8d8bfe2", + "url": "https://api.github.com/repos/symfony/console/zipball/8b1008344647462ae6ec57559da166c2bfa5e16a", + "reference": "8b1008344647462ae6ec57559da166c2bfa5e16a", "shasum": "" }, "require": { @@ -5392,7 +5392,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.3.6" + "source": "https://github.com/symfony/console/tree/v5.3.7" }, "funding": [ { @@ -5408,7 +5408,7 @@ "type": "tidelift" } ], - "time": "2021-07-27T19:10:22+00:00" + "time": "2021-08-25T20:02:16+00:00" }, { "name": "symfony/deprecation-contracts", @@ -5882,16 +5882,16 @@ }, { "name": "symfony/string", - "version": "v5.3.3", + "version": "v5.3.7", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1" + "reference": "8d224396e28d30f81969f083a58763b8b9ceb0a5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1", - "reference": "bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1", + "url": "https://api.github.com/repos/symfony/string/zipball/8d224396e28d30f81969f083a58763b8b9ceb0a5", + "reference": "8d224396e28d30f81969f083a58763b8b9ceb0a5", "shasum": "" }, "require": { @@ -5945,7 +5945,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.3.3" + "source": "https://github.com/symfony/string/tree/v5.3.7" }, "funding": [ { @@ -5961,7 +5961,7 @@ "type": "tidelift" } ], - "time": "2021-06-27T11:44:38+00:00" + "time": "2021-08-26T08:00:08+00:00" }, { "name": "theseer/tokenizer", @@ -6251,7 +6251,7 @@ "aliases": [ { "package": "utopia-php/database", - "version": "dev-feat-adjusted-query-validator", + "version": "dev-feat-check-attribute-method", "alias": "0.10.0", "alias_normalized": "0.10.0.0" } From ae58a600659031a7d3669fa4dce824a83e06ce57 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Tue, 31 Aug 2021 21:13:58 -0400 Subject: [PATCH 07/13] Use checkAttribute to catch index limits --- app/controllers/api/database.php | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index 609ffc7aab..7cda576626 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -56,17 +56,6 @@ $attributesCallback = function ($collectionId, $attribute, $response, $dbForInte throw new Exception('Collection not found', 404); } - $count = $dbForInternal->count('attributes', [ - new Query('collectionId', Query::TYPE_EQUAL, [$collectionId]) - ], 1012); - - // 1017 limit minus default attributes and one buffer for virtual columns - $limit = 1017 - MariaDB::getNumberOfDefaultAttributes() - 1; - - if ($count >= $limit) { - throw new Exception('Attribute limit exceeded', 400); - } - // TODO@kodumbeats how to depend on $size for Text validator length // Ensure attribute default is within required size if ($size > 0 && !\is_null($default)) { @@ -82,8 +71,7 @@ $attributesCallback = function ($collectionId, $attribute, $response, $dbForInte } } - try { - $attribute = $dbForInternal->createDocument('attributes', new Document([ + $attribute = new Document([ '$id' => $collectionId.'_'.$attributeId, 'key' => $attributeId, 'collectionId' => $collectionId, @@ -96,8 +84,16 @@ $attributesCallback = function ($collectionId, $attribute, $response, $dbForInte 'array' => $array, 'format' => $format, 'formatOptions' => $formatOptions, - 'filters' => $filters, - ])); + ]); + + try { + $dbForInternal->checkAttribute($collection, $attribute); + } catch (LimitException $exception) { + throw new Exception('Attribute limit exceeded', 400); + } + + try { + $attribute = $dbForInternal->createDocument('attributes', $attribute); } catch (DuplicateException $th) { throw new Exception('Attribute already exists', 409); } catch (LimitException $e) { From be47d162907dffb4e486e9d56bb23bbfd0d30bd4 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Wed, 1 Sep 2021 10:08:59 -0400 Subject: [PATCH 08/13] Use MariaDB max limit for index/attribute subqueries --- app/init.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/init.php b/app/init.php index 57f2dc7130..d68f9f4851 100644 --- a/app/init.php +++ b/app/init.php @@ -184,7 +184,7 @@ Database::addFilter('subQueryAttributes', return $database ->find('attributes', [ new Query('collectionId', Query::TYPE_EQUAL, [$document->getId()]) - ], 100, 0, []); + ], 1017, 0, []); } ); @@ -196,7 +196,7 @@ Database::addFilter('subQueryIndexes', return $database ->find('indexes', [ new Query('collectionId', Query::TYPE_EQUAL, [$document->getId()]) - ], 100, 0, []); + ], 64, 0, []); } ); From 624d099bf9b71aabb598b658f60a807268e8dc78 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Wed, 1 Sep 2021 10:36:01 -0400 Subject: [PATCH 09/13] Assert row width exception is thrown --- tests/e2e/Services/Database/DatabaseCustomServerTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/e2e/Services/Database/DatabaseCustomServerTest.php b/tests/e2e/Services/Database/DatabaseCustomServerTest.php index 2be62f8fa8..6c0a500756 100644 --- a/tests/e2e/Services/Database/DatabaseCustomServerTest.php +++ b/tests/e2e/Services/Database/DatabaseCustomServerTest.php @@ -398,8 +398,8 @@ class DatabaseCustomServerTest extends Scope 'required' => true, ]); - // $this->assertEquals(400, $tooWide['headers']['status-code']); - // $this->assertEquals('Attribute limit exceeded', $tooWide['body']['message']); + $this->assertEquals(400, $tooWide['headers']['status-code']); + $this->assertEquals('Attribute limit exceeded', $tooWide['body']['message']); } public function testIndexLimitException() From f5d69b4b0aaaba03480323d798097412179f2811 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Thu, 9 Sep 2021 13:15:30 -0400 Subject: [PATCH 10/13] Catch exceptions in one block --- app/controllers/api/database.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index 7cda576626..5560d931d9 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -88,16 +88,13 @@ $attributesCallback = function ($collectionId, $attribute, $response, $dbForInte try { $dbForInternal->checkAttribute($collection, $attribute); - } catch (LimitException $exception) { - throw new Exception('Attribute limit exceeded', 400); - } - - try { $attribute = $dbForInternal->createDocument('attributes', $attribute); - } catch (DuplicateException $th) { + } + catch (DuplicateException $exception) { throw new Exception('Attribute already exists', 409); - } catch (LimitException $e) { - throw new Exception($e->getMessage(), 400); + } + catch (LimitException $exception) { + throw new Exception('Attribute limit exceeded', 400); } $dbForInternal->purgeDocument('collections', $collectionId); From 38a6e147c2cc05438074cff84aa92b6b7ab461f3 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Thu, 16 Sep 2021 21:52:35 -0400 Subject: [PATCH 11/13] Use limits defined by database library --- app/init.php | 4 ++-- composer.json | 2 +- composer.lock | 50 +++++++++++++++++++++++++------------------------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/app/init.php b/app/init.php index d68f9f4851..c5a15cc734 100644 --- a/app/init.php +++ b/app/init.php @@ -184,7 +184,7 @@ Database::addFilter('subQueryAttributes', return $database ->find('attributes', [ new Query('collectionId', Query::TYPE_EQUAL, [$document->getId()]) - ], 1017, 0, []); + ], $database->getAttributeLimit(), 0, []); } ); @@ -196,7 +196,7 @@ Database::addFilter('subQueryIndexes', return $database ->find('indexes', [ new Query('collectionId', Query::TYPE_EQUAL, [$document->getId()]) - ], 64, 0, []); + ], $database->getIndexLimit(), 0, []); } ); diff --git a/composer.json b/composer.json index 9bd152fb92..c51501f712 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-check-attribute-method as 0.10.0", + "utopia-php/database": "dev-feat-get-limit-methods-on-database as 0.10.0", "utopia-php/locale": "0.4.*", "utopia-php/registry": "0.5.*", "utopia-php/preloader": "0.2.*", diff --git a/composer.lock b/composer.lock index 829e348201..b6418d1482 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": "9a7739aabd503572b8010be91192b144", + "content-hash": "ffd14884e3b377752bdb699c5693cb0d", "packages": [ { "name": "adhocore/jwt", @@ -248,16 +248,16 @@ }, { "name": "chillerlan/php-settings-container", - "version": "2.1.1", + "version": "2.1.2", "source": { "type": "git", "url": "https://github.com/chillerlan/php-settings-container.git", - "reference": "98ccc1b31b31a53bcb563465c4961879b2b93096" + "reference": "ec834493a88682dd69652a1eeaf462789ed0c5f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/chillerlan/php-settings-container/zipball/98ccc1b31b31a53bcb563465c4961879b2b93096", - "reference": "98ccc1b31b31a53bcb563465c4961879b2b93096", + "url": "https://api.github.com/repos/chillerlan/php-settings-container/zipball/ec834493a88682dd69652a1eeaf462789ed0c5f5", + "reference": "ec834493a88682dd69652a1eeaf462789ed0c5f5", "shasum": "" }, "require": { @@ -307,7 +307,7 @@ "type": "ko_fi" } ], - "time": "2021-01-06T15:57:03+00:00" + "time": "2021-09-06T15:17:01+00:00" }, { "name": "colinmollenhour/credis", @@ -355,16 +355,16 @@ }, { "name": "composer/package-versions-deprecated", - "version": "1.11.99.3", + "version": "1.11.99.4", "source": { "type": "git", "url": "https://github.com/composer/package-versions-deprecated.git", - "reference": "fff576ac850c045158a250e7e27666e146e78d18" + "reference": "b174585d1fe49ceed21928a945138948cb394600" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/fff576ac850c045158a250e7e27666e146e78d18", - "reference": "fff576ac850c045158a250e7e27666e146e78d18", + "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/b174585d1fe49ceed21928a945138948cb394600", + "reference": "b174585d1fe49ceed21928a945138948cb394600", "shasum": "" }, "require": { @@ -408,7 +408,7 @@ "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", "support": { "issues": "https://github.com/composer/package-versions-deprecated/issues", - "source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.3" + "source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.4" }, "funding": [ { @@ -424,7 +424,7 @@ "type": "tidelift" } ], - "time": "2021-08-17T13:49:14+00:00" + "time": "2021-09-13T08:41:34+00:00" }, { "name": "dragonmantank/cron-expression", @@ -1984,11 +1984,11 @@ }, { "name": "utopia-php/database", - "version": "dev-feat-check-attribute-method", + "version": "dev-feat-get-limit-methods-on-database", "source": { "type": "git", "url": "https://github.com/utopia-php/database", - "reference": "2d1f48345f1284876f6847599c66eee145b7233e" + "reference": "4cc9d5eb9c6be1a9116a4d9dc2e6bd9db4e8e9c0" }, "require": { "ext-mongodb": "*", @@ -2037,7 +2037,7 @@ "upf", "utopia" ], - "time": "2021-09-01T00:50:12+00:00" + "time": "2021-09-17T01:44:11+00:00" }, { "name": "utopia-php/domains", @@ -3761,33 +3761,33 @@ }, { "name": "phpspec/prophecy", - "version": "1.13.0", + "version": "1.14.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea" + "reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/be1996ed8adc35c3fd795488a653f4b518be70ea", - "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e", + "reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e", "shasum": "" }, "require": { "doctrine/instantiator": "^1.2", - "php": "^7.2 || ~8.0, <8.1", + "php": "^7.2 || ~8.0, <8.2", "phpdocumentor/reflection-docblock": "^5.2", "sebastian/comparator": "^3.0 || ^4.0", "sebastian/recursion-context": "^3.0 || ^4.0" }, "require-dev": { - "phpspec/phpspec": "^6.0", + "phpspec/phpspec": "^6.0 || ^7.0", "phpunit/phpunit": "^8.0 || ^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.11.x-dev" + "dev-master": "1.x-dev" } }, "autoload": { @@ -3822,9 +3822,9 @@ ], "support": { "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/1.13.0" + "source": "https://github.com/phpspec/prophecy/tree/1.14.0" }, - "time": "2021-03-17T13:42:18+00:00" + "time": "2021-09-10T09:02:12+00:00" }, { "name": "phpunit/php-code-coverage", @@ -6251,7 +6251,7 @@ "aliases": [ { "package": "utopia-php/database", - "version": "dev-feat-check-attribute-method", + "version": "dev-feat-get-limit-methods-on-database", "alias": "0.10.0", "alias_normalized": "0.10.0.0" } From 0f5931555aa3024e2d1b6e68b4d9610a5e2a24d2 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Tue, 5 Oct 2021 09:57:57 -0400 Subject: [PATCH 12/13] Fix issues from merge --- app/controllers/api/database.php | 5 ++--- src/Appwrite/Utopia/Response/Model/Collection.php | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index ecbc896d01..255293c040 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -77,7 +77,7 @@ function createAttribute($collectionId, $attribute, $response, $dbForInternal, $ } try { - $attribute = $dbForInternal->createDocument('attributes', new Document([ + $attribute = new Document([ '$id' => $collectionId.'_'.$attributeId, 'key' => $attributeId, 'collectionId' => $collectionId, @@ -90,9 +90,8 @@ function createAttribute($collectionId, $attribute, $response, $dbForInternal, $ 'array' => $array, 'format' => $format, 'formatOptions' => $formatOptions, - ]); + ]); - try { $dbForInternal->checkAttribute($collection, $attribute); $attribute = $dbForInternal->createDocument('attributes', $attribute); } diff --git a/src/Appwrite/Utopia/Response/Model/Collection.php b/src/Appwrite/Utopia/Response/Model/Collection.php index e46603fd9a..331dd48b0a 100644 --- a/src/Appwrite/Utopia/Response/Model/Collection.php +++ b/src/Appwrite/Utopia/Response/Model/Collection.php @@ -55,14 +55,14 @@ class Collection extends Model ], 'description' => 'Collection attributes.', 'default' => [], - 'example' => new stdClass, + 'example' => new \stdClass, 'array' => true, ]) ->addRule('indexes', [ 'type' => Response::MODEL_INDEX, 'description' => 'Collection indexes.', 'default' => [], - 'example' => new stdClass, + 'example' => new \stdClass, 'array' => true ]) ; From bc0a15e38bbd356275ee02c21a84cd9720a725ab Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Tue, 5 Oct 2021 16:27:06 +0200 Subject: [PATCH 13/13] fix usage worker --- app/tasks/usage.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/tasks/usage.php b/app/tasks/usage.php index 4ff5e8cad9..701037fcca 100644 --- a/app/tasks/usage.php +++ b/app/tasks/usage.php @@ -342,7 +342,7 @@ $cli do { // list projects try { $attempts++; - $projects = $dbForConsole->find('projects', [], 100, orderAfter:$latestProject); + $projects = $dbForConsole->find('projects', [], 100, cursor:$latestProject); break; // leave the do-while if successful } catch (\Exception $e) { Console::warning("Console DB not ready yet. Retrying ({$attempts})..."); @@ -472,7 +472,7 @@ $cli do { // Loop over all the parent collection document for each sub collection $dbForProject->setNamespace("project_{$projectId}_{$options['namespace']}"); - $parents = $dbForProject->find($collection, [], 100, orderAfter:$latestParent); // Get all the parents for the sub collections for example for documents, this will get all the collections + $parents = $dbForProject->find($collection, [], 100, cursor:$latestParent); // Get all the parents for the sub collections for example for documents, this will get all the collections if (empty($parents)) { continue;