From 65ab721c3d79c57252faec06e1b42fbf4f0586ac Mon Sep 17 00:00:00 2001 From: fogelito Date: Tue, 9 Apr 2024 15:32:23 +0300 Subject: [PATCH 1/4] InvalidRelationshipValue --- app/controllers/general.php | 4 ++ composer.lock | 78 +++++++++++++++---------------- src/Appwrite/Extend/Exception.php | 3 ++ 3 files changed, 46 insertions(+), 39 deletions(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index 13a86ac36b..1828f0676e 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -847,6 +847,10 @@ App::error() \var_dump('Wrapping authorization exception'); $error = new AppwriteException(AppwriteException::USER_UNAUTHORIZED); break; + case 'Utopia\Database\Exception\InvalidRelationshipValue': + \var_dump('Wrapping relationship exception'); + $error = new AppwriteException(AppwriteException::INVALID_RELATIONSHIP_VALUE); + break; } $code = $error->getCode(); diff --git a/composer.lock b/composer.lock index 606338c675..b222b44f8f 100644 --- a/composer.lock +++ b/composer.lock @@ -156,15 +156,15 @@ }, { "name": "appwrite/php-runtimes", - "version": "0.13.3", + "version": "0.13.5", "source": { "type": "git", "url": "https://github.com/appwrite/runtimes.git", - "reference": "5d93fc578a9a543bcdc9b2c0562d80a51d56c73d" + "reference": "ba24c3a163f1a1da6cd355db92def508d05e59f7" }, "require": { "php": ">=8.0", - "utopia-php/system": "0.7.*" + "utopia-php/system": "0.8.*" }, "require-dev": { "phpunit/phpunit": "^9.3", @@ -195,7 +195,7 @@ "php", "runtimes" ], - "time": "2024-03-01T14:47:47+00:00" + "time": "2024-04-01T10:35:02+00:00" }, { "name": "chillerlan/php-qrcode", @@ -1041,16 +1041,16 @@ }, { "name": "utopia-php/cache", - "version": "0.9.0", + "version": "0.9.1", "source": { "type": "git", "url": "https://github.com/utopia-php/cache.git", - "reference": "4fc7b4789b5f0ce74835c1ecfec4f3afe6f0e34e" + "reference": "552b4c554bb14d0c529631ce304cdf4a2b9d06a6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/cache/zipball/4fc7b4789b5f0ce74835c1ecfec4f3afe6f0e34e", - "reference": "4fc7b4789b5f0ce74835c1ecfec4f3afe6f0e34e", + "url": "https://api.github.com/repos/utopia-php/cache/zipball/552b4c554bb14d0c529631ce304cdf4a2b9d06a6", + "reference": "552b4c554bb14d0c529631ce304cdf4a2b9d06a6", "shasum": "" }, "require": { @@ -1085,9 +1085,9 @@ ], "support": { "issues": "https://github.com/utopia-php/cache/issues", - "source": "https://github.com/utopia-php/cache/tree/0.9.0" + "source": "https://github.com/utopia-php/cache/tree/0.9.1" }, - "time": "2024-01-07T18:11:23+00:00" + "time": "2024-03-19T17:07:20+00:00" }, { "name": "utopia-php/cli", @@ -1393,16 +1393,16 @@ }, { "name": "utopia-php/framework", - "version": "0.33.3", + "version": "0.33.6", "source": { "type": "git", "url": "https://github.com/utopia-php/http.git", - "reference": "893d602cd96676810c25fc9b9a2e9360eebb898f" + "reference": "8fe57da0cecd57e3b17cd395b4a666a24f4c07a6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/http/zipball/893d602cd96676810c25fc9b9a2e9360eebb898f", - "reference": "893d602cd96676810c25fc9b9a2e9360eebb898f", + "url": "https://api.github.com/repos/utopia-php/http/zipball/8fe57da0cecd57e3b17cd395b4a666a24f4c07a6", + "reference": "8fe57da0cecd57e3b17cd395b4a666a24f4c07a6", "shasum": "" }, "require": { @@ -1432,9 +1432,9 @@ ], "support": { "issues": "https://github.com/utopia-php/http/issues", - "source": "https://github.com/utopia-php/http/tree/0.33.3" + "source": "https://github.com/utopia-php/http/tree/0.33.6" }, - "time": "2024-03-11T13:43:23+00:00" + "time": "2024-03-21T18:10:57+00:00" }, { "name": "utopia-php/image", @@ -2062,16 +2062,16 @@ }, { "name": "utopia-php/storage", - "version": "0.18.3", + "version": "0.18.4", "source": { "type": "git", "url": "https://github.com/utopia-php/storage.git", - "reference": "faa0279519ac14f3501e8b138e0865ad9d12bff6" + "reference": "94ab8758fabcefee5c5fa723616e45719833f922" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/storage/zipball/faa0279519ac14f3501e8b138e0865ad9d12bff6", - "reference": "faa0279519ac14f3501e8b138e0865ad9d12bff6", + "url": "https://api.github.com/repos/utopia-php/storage/zipball/94ab8758fabcefee5c5fa723616e45719833f922", + "reference": "94ab8758fabcefee5c5fa723616e45719833f922", "shasum": "" }, "require": { @@ -2111,9 +2111,9 @@ ], "support": { "issues": "https://github.com/utopia-php/storage/issues", - "source": "https://github.com/utopia-php/storage/tree/0.18.3" + "source": "https://github.com/utopia-php/storage/tree/0.18.4" }, - "time": "2023-12-31T11:45:12+00:00" + "time": "2024-04-02T08:24:09+00:00" }, { "name": "utopia-php/swoole", @@ -2168,16 +2168,16 @@ }, { "name": "utopia-php/system", - "version": "0.7.2", + "version": "0.8.0", "source": { "type": "git", "url": "https://github.com/utopia-php/system.git", - "reference": "4593d4d334b0c15879c4744a826e0362924c5d66" + "reference": "a2cbfb3c69b9ecb8b6f06c5774f3cf279ea7665e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/system/zipball/4593d4d334b0c15879c4744a826e0362924c5d66", - "reference": "4593d4d334b0c15879c4744a826e0362924c5d66", + "url": "https://api.github.com/repos/utopia-php/system/zipball/a2cbfb3c69b9ecb8b6f06c5774f3cf279ea7665e", + "reference": "a2cbfb3c69b9ecb8b6f06c5774f3cf279ea7665e", "shasum": "" }, "require": { @@ -2218,9 +2218,9 @@ ], "support": { "issues": "https://github.com/utopia-php/system/issues", - "source": "https://github.com/utopia-php/system/tree/0.7.2" + "source": "https://github.com/utopia-php/system/tree/0.8.0" }, - "time": "2023-10-20T01:39:17+00:00" + "time": "2024-04-01T10:22:28+00:00" }, { "name": "utopia-php/vcs", @@ -3220,16 +3220,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.26.0", + "version": "1.28.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "231e3186624c03d7e7c890ec662b81e6b0405227" + "reference": "cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/231e3186624c03d7e7c890ec662b81e6b0405227", - "reference": "231e3186624c03d7e7c890ec662b81e6b0405227", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb", + "reference": "cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb", "shasum": "" }, "require": { @@ -3261,9 +3261,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.26.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.28.0" }, - "time": "2024-02-23T16:05:55+00:00" + "time": "2024-04-03T18:51:33+00:00" }, { "name": "phpunit/php-code-coverage", @@ -4702,16 +4702,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.9.0", + "version": "3.9.1", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b" + "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/d63cee4890a8afaf86a22e51ad4d97c91dd4579b", - "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/267a4405fff1d9c847134db3a3c92f1ab7f77909", + "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909", "shasum": "" }, "require": { @@ -4778,7 +4778,7 @@ "type": "open_collective" } ], - "time": "2024-02-16T15:06:51+00:00" + "time": "2024-03-31T21:03:09+00:00" }, { "name": "swoole/ide-helper", diff --git a/src/Appwrite/Extend/Exception.php b/src/Appwrite/Extend/Exception.php index 5d5d1b8f1f..4ef4604164 100644 --- a/src/Appwrite/Extend/Exception.php +++ b/src/Appwrite/Extend/Exception.php @@ -176,6 +176,9 @@ class Exception extends \Exception public const ATTRIBUTE_VALUE_INVALID = 'attribute_value_invalid'; public const ATTRIBUTE_TYPE_INVALID = 'attribute_type_invalid'; + /** Relationship */ + public const INVALID_RELATIONSHIP_VALUE = 'invalid_relationship_value'; + /** Indexes */ public const INDEX_NOT_FOUND = 'index_not_found'; public const INDEX_LIMIT_EXCEEDED = 'index_limit_exceeded'; From 12434fd8460370e359fc013436e66e20466d58f7 Mon Sep 17 00:00:00 2001 From: fogelito Date: Tue, 9 Apr 2024 15:38:55 +0300 Subject: [PATCH 2/4] RELATIONSHIP_VALUE_INVALID --- app/config/errors.php | 5 +++++ app/controllers/general.php | 2 +- src/Appwrite/Extend/Exception.php | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/config/errors.php b/app/config/errors.php index 1699157d8c..866a29cf80 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -592,6 +592,11 @@ return [ 'description' => 'The attribute type is invalid.', 'code' => 400, ], + Exception::RELATIONSHIP_VALUE_INVALID => [ + 'name' => Exception::RELATIONSHIP_VALUE_INVALID, + 'description' => 'The relationship value is invalid.', + 'code' => 400, + ], /** Indexes */ Exception::INDEX_NOT_FOUND => [ diff --git a/app/controllers/general.php b/app/controllers/general.php index 1828f0676e..60aa1ca5f4 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -849,7 +849,7 @@ App::error() break; case 'Utopia\Database\Exception\InvalidRelationshipValue': \var_dump('Wrapping relationship exception'); - $error = new AppwriteException(AppwriteException::INVALID_RELATIONSHIP_VALUE); + $error = new AppwriteException(AppwriteException::RELATIONSHIP_VALUE_INVALID); break; } diff --git a/src/Appwrite/Extend/Exception.php b/src/Appwrite/Extend/Exception.php index 4ef4604164..ccc81a471e 100644 --- a/src/Appwrite/Extend/Exception.php +++ b/src/Appwrite/Extend/Exception.php @@ -177,7 +177,7 @@ class Exception extends \Exception public const ATTRIBUTE_TYPE_INVALID = 'attribute_type_invalid'; /** Relationship */ - public const INVALID_RELATIONSHIP_VALUE = 'invalid_relationship_value'; + public const RELATIONSHIP_VALUE_INVALID = 'relationship_value_invalid'; /** Indexes */ public const INDEX_NOT_FOUND = 'index_not_found'; From 00ebf5c10fe82bc81ddb6a9919a34d1680fea844 Mon Sep 17 00:00:00 2001 From: fogelito Date: Thu, 11 Apr 2024 10:46:18 +0300 Subject: [PATCH 3/4] Remove var_dumps --- app/controllers/general.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index 60aa1ca5f4..9bb1a587ac 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -820,35 +820,27 @@ App::error() } break; case 'Utopia\Database\Exception\Conflict': - \var_dump('Wrapping conflict exception'); $error = new AppwriteException(AppwriteException::DOCUMENT_UPDATE_CONFLICT, previous: $error); break; case 'Utopia\Database\Exception\Timeout': - \var_dump('Wrapping timeout exception'); $error = new AppwriteException(AppwriteException::DATABASE_TIMEOUT, previous: $error); break; case 'Utopia\Database\Exception\Query': - \var_dump('Wrapping query exception'); $error = new AppwriteException(AppwriteException::GENERAL_QUERY_INVALID, $error->getMessage(), previous: $error); break; case 'Utopia\Database\Exception\Structure': - \var_dump('Wrapping structure exception'); $error = new AppwriteException(AppwriteException::DOCUMENT_INVALID_STRUCTURE, $error->getMessage(), previous: $error); break; case 'Utopia\Database\Exception\Duplicate': - \var_dump('Wrapping duplicate exception'); $error = new AppwriteException(AppwriteException::DOCUMENT_ALREADY_EXISTS); break; case 'Utopia\Database\Exception\Restricted': - \var_dump('Wrapping restricted exception'); $error = new AppwriteException(AppwriteException::DOCUMENT_DELETE_RESTRICTED); break; case 'Utopia\Database\Exception\Authorization': - \var_dump('Wrapping authorization exception'); $error = new AppwriteException(AppwriteException::USER_UNAUTHORIZED); break; case 'Utopia\Database\Exception\InvalidRelationshipValue': - \var_dump('Wrapping relationship exception'); $error = new AppwriteException(AppwriteException::RELATIONSHIP_VALUE_INVALID); break; } From bec10c005233822cf8f83e1c00a57feb77a5d01a Mon Sep 17 00:00:00 2001 From: fogelito Date: Thu, 11 Apr 2024 10:49:45 +0300 Subject: [PATCH 4/4] Add previous Error --- 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 9bb1a587ac..61217a248e 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -841,7 +841,7 @@ App::error() $error = new AppwriteException(AppwriteException::USER_UNAUTHORIZED); break; case 'Utopia\Database\Exception\InvalidRelationshipValue': - $error = new AppwriteException(AppwriteException::RELATIONSHIP_VALUE_INVALID); + $error = new AppwriteException(AppwriteException::RELATIONSHIP_VALUE_INVALID, $error->getMessage(), previous: $error); break; }