Skip to content
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

Unable to delete User #16340

Closed
ThomasKuehner opened this issue Jul 10, 2019 · 11 comments · Fixed by #17494
Closed

Unable to delete User #16340

ThomasKuehner opened this issue Jul 10, 2019 · 11 comments · Fixed by #17494
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug

Comments

@ThomasKuehner
Copy link

Steps to reproduce

  1. add new user with a php-skript
  2. add Attribute 'address' extrakted from a csv.file in ANSI that contains a "ß" (no Problem with UTF-8)
  3. login as admin in the nextcloud webinterface

Actual behaviour

  • User dont appear in Users --> everyone
    when scrolling down: all users, who would be listed after that user are not listed and the message "An error occured during the request. Unable to proceed" appears
    in loggig appears:
    TypeError: Argument 1 passed to OC\Accounts\AccountManager::addMissingDefaultValues() must be of the type array, null given, called in /var/www/html/nextcloud/lib/private/Accounts/AccountManager.php on line 139 at /var/www/html/nextcloud/lib/private/Accounts/AccountManager.php#176
  • when clicking on a Group this user is a member of, none of the users is shown and the message "An error occured during the request. Unable to proceed" appears.
  • It is impossible to delete the user in the web interface because he is not listed.

With a php skript following oparations work:

  • Get users: shows all users and inclusive that user
  • Get groups that user is a member of
  • Add that user to a group
  • Change the Attribute 'displayname'

With a php skript following oparations do not work:

  • Disabe that user
  • Delete that user
  • Change the attribute 'address'
  • Remove that user from a group
  • Change the password of that user
    always the same log-message: TypeError: Argument 1 passed to OC\Accounts\AccountManager::addMissingDefaultValues() must be of the type array, null given, called in /var/www/html/nextcloud/lib/private/Accounts/AccountManager.php on line 139 at /var/www/html/nextcloud/lib/private/Accounts/AccountManager.php#176

Server configuration

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

Is there a quick solution to get rid of this user?

@ThomasKuehner ThomasKuehner added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Jul 10, 2019
@kesselb
Copy link
Contributor

kesselb commented Jul 10, 2019

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

@ThomasKuehner
Copy link
Author

This patch works fine !
Thank you very very much!!!!!!!!

@wiswedel
Copy link
Contributor

@ThomasKuehner So can this issue be closed as resolved?

@systems-levigo
Copy link

systems-levigo commented Oct 9, 2019

@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.

@kesselb
Copy link
Contributor

kesselb commented Oct 9, 2019

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.

@systems-levigo
Copy link

systems-levigo commented Oct 10, 2019

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.

@ChristophWurst
Copy link
Member

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?

@systems-levigo
Copy link

Did you run manual SQL queries to modify it?

We know of no changes directly in the database.

@kesselb
Copy link
Contributor

kesselb commented Dec 13, 2019

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 ;)

@systems-levigo
Copy link

systems-levigo commented Dec 17, 2019

Is there a way to fix the broken JSON entry's manually?
Otherwise after every update the patch most be applied.

@ChristophWurst
Copy link
Member

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 #17494

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants