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/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); }); 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); }); 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':