With a php skript following oparations work:
With a php skript following oparations do not work:
Operating system:
Ubuntu 18-04 server
Web server:
apache2
Database:
mariadb-server
PHP version:
PHP 7.2.19
Nextcloud version: (see Nextcloud admin page)
Nextcloud 16.0.3
Updated from an older Nextcloud/ownCloud or fresh install:
fresh install
Where did you install Nextcloud from:
wget https://download.nextcloud.com/server/releases/latest.tar.bz2
List of activated apps:
calendar
Are you using encryption: yes/no
no
Hmm. Not sure how to reproduce properly. We restore some json encoded data from the database but could not decode it. Please backup your database before you try to patch below. No warranty.
Index: lib/private/Accounts/AccountManager.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- lib/private/Accounts/AccountManager.php (revision 5c9b19289be0aa195fb0d8e26952c6558464c6cc)
+++ lib/private/Accounts/AccountManager.php (date 1562802719000)
@@ -135,6 +135,9 @@
}
$userDataArray = json_decode($result[0]['data'], true);
+ if ($userDataArray === null || json_last_error() !== JSON_ERROR_NONE) {
+ $userDataArray = $this->buildDefaultUserRecord($user);
+ }
$userDataArray = $this->addMissingDefaultValues($userDataArray);
cc @schiessle
This patch works fine !
Thank you very very much!!!!!!!!
@ThomasKuehner So can this issue be closed as resolved?
@wiswedel this fix should be added into the code. Otherwise you have to change the code after every update. We got the same issue after migrating Owncloud to Nextcloud and the snippet fixed it.
Index: lib/private/Accounts/AccountManager.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- lib/private/Accounts/AccountManager.php (revision 99358d70e88e42af72a38154945efa71229779c3)
+++ lib/private/Accounts/AccountManager.php (date 1570626720250)
@@ -135,6 +135,10 @@
}
$userDataArray = json_decode($result[0]['data'], true);
+ if ($userDataArray === null || json_last_error() !== JSON_ERROR_NONE) {
+ \OC::$server->getLogger()->warning('Could not decode data from db: ' . json_last_error_msg());
+ $userDataArray = $this->buildDefaultUserRecord($user);
+ }
$userDataArray = $this->addMissingDefaultValues($userDataArray);
@levigo-systems mind to apply this patch? I'm still not sure how to push the wrong data into the db.
A better way would be to deploy a fix for the invalid JSON in the oc_accounts table. Maybe a new CLI command "db:convert-invalid-json" or something like that.
But if that's not possible i recommend to apply this patch above.
We can integrate the patch. But the patch just does the damage control after the bug. It doesn't fix the bug that we even insert invalid json.
Does anyone know where this might come from? Did you run manual SQL queries to modify it?
Did you run manual SQL queries to modify it?
We know of no changes directly in the database.
add new user with a php-skript
Probably they use some app to create users. I agree to @ChristophWurst and @levigo-systems in general (fix bugs instead of adding workarounds) but our code should not fail if some more or less important data is missing ;)
Is there a way to fix the broken JSON entry's manually?
Otherwise after every update the patch most be applied.
Is there a way to fix the broken JSON entry's manually?
Inspect the row, fix it and update the row
Otherwise after every update the patch most be applied.
No, you don't as of https://github.com/nextcloud/server/pull/17494