-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return a default user record if json is broken #17494
Conversation
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>
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for @kesselb's fix.
Added some logging so this doesn't happen unnoticed.
c9511c6
to
b97d90e
Compare
@@ -137,6 +146,11 @@ public function getUser(IUser $user) { | |||
} | |||
|
|||
$userDataArray = json_decode($result[0]['data'], true); | |||
$jsonError = json_last_error(); | |||
if ($userDataArray === null || $jsonError !== JSON_ERROR_NONE) { | |||
$this->logger->critical("User data of $uid contained invalid JSON (error $jsonError), hence falling back to a default user record"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
json_last_error_msg()
would log a readable error message. But the numeric code is also fine for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't know about that!
For the sake of finally getting this in for 18 I'll leave it as is :)
CI looks good to me. |
/backport to stable17 |
/backport to stable16 |
The backport to stable17 failed. Please do this backport manually. |
The backport to stable16 failed. Please do this backport manually. |
18 is fine for me. We can backport it later if necessary. |
Fix #16340
It's possible that json_decode returns null. Mostly the json is broken.
AddMissingDefaultValues expects an array. Pass null will fail.
How to reproduce: Modify the json in oc_accounts.
Not sure if we need some repair job to kill those broken records. Looks like an edge case to me.