Return a default user record if json is broken

It's possible that json_decode returns null. Mostly the json is broken.
AddMissingDefaultValues expects an array. Pass null will fail.

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
This commit is contained in:
Daniel Kesselberg 2019-10-09 17:43:54 +02:00 committed by Christoph Wurst
parent 642606754b
commit bbe41a73dd
No known key found for this signature in database
GPG Key ID: CC42AC2A7F0E56D8
1 changed files with 3 additions and 0 deletions

View File

@ -137,6 +137,9 @@ class AccountManager implements IAccountManager {
}
$userDataArray = json_decode($result[0]['data'], true);
if ($userDataArray === null || json_last_error() !== JSON_ERROR_NONE) {
return $this->buildDefaultUserRecord($user);
}
$userDataArray = $this->addMissingDefaultValues($userDataArray);