From 3009168350b19153b45709d7c1a33d2d4487315f Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 12 Apr 2023 17:48:36 +0200 Subject: [PATCH 1/3] fix: migration for 1.3.x --- src/Appwrite/Migration/Version/V18.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Migration/Version/V18.php b/src/Appwrite/Migration/Version/V18.php index 2fedf4957e..eba19fa861 100644 --- a/src/Appwrite/Migration/Version/V18.php +++ b/src/Appwrite/Migration/Version/V18.php @@ -33,9 +33,7 @@ class V18 extends Migration $this->migrateCollections(); Console::info('Migrating Documents'); - $this->forEachDocument(function (Document $document) { - $this->migrateDocument($document); - }); + $this->forEachDocument([$this, 'fixDocument']); } /** @@ -131,7 +129,7 @@ class V18 extends Migration * @param Document $document * @return Document */ - private function migrateDocument(Document $document): Document + protected function fixDocument(Document $document): Document { switch ($document->getCollection()) { case 'projects': From 52d7dcf08260accaf1edaa413a70aca5a121bd17 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 12 Apr 2023 18:02:43 +0200 Subject: [PATCH 2/3] fix: update prefs endpoints to not fallback to stdClass --- app/controllers/api/account.php | 2 +- app/controllers/api/users.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 11d67232c7..dd5ac4a2da 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -1356,7 +1356,7 @@ App::get('/v1/account/prefs') ->inject('user') ->action(function (Response $response, Document $user) { - $prefs = $user->getAttribute('prefs', new \stdClass()); + $prefs = $user->getAttribute('prefs', []); $response->dynamic(new Document($prefs), Response::MODEL_PREFERENCES); }); diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 7e7e342de9..ceed901a32 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -457,7 +457,7 @@ App::get('/v1/users/:userId/prefs') throw new Exception(Exception::USER_NOT_FOUND); } - $prefs = $user->getAttribute('prefs', new \stdClass()); + $prefs = $user->getAttribute('prefs', []); $response->dynamic(new Document($prefs), Response::MODEL_PREFERENCES); }); From 34d27fb4d0e74b31e334b0a8618ab70efd2a8858 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 12 Apr 2023 18:03:08 +0200 Subject: [PATCH 3/3] fix: prefs for teams --- app/controllers/api/teams.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index fbe7fd5398..338af70406 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -223,7 +223,7 @@ App::get('/v1/teams/:teamId/prefs') throw new Exception(Exception::TEAM_NOT_FOUND); } - $prefs = $team->getAttribute('prefs', new \stdClass()); + $prefs = $team->getAttribute('prefs', []); $response->dynamic(new Document($prefs), Response::MODEL_PREFERENCES); });