summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2018-10-26 17:38:42 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2018-10-30 12:12:03 +0100
commit49456e42f958bec9b0fc9d07c5ec37ff51cc9351 (patch)
treeff7a1c300aa4cedb0387dc5286cc1fa6c756b49d /apps/user_ldap/lib
parentbbe44108b5661d0c3935fa76e27abbc433fd458e (diff)
downloadnextcloud-server-49456e42f958bec9b0fc9d07c5ec37ff51cc9351.tar.gz
nextcloud-server-49456e42f958bec9b0fc9d07c5ec37ff51cc9351.zip
do not run into UniqueConstraintViolationException
… when an unmapped user logs in for the first time when background job mode is ajax and no memcache was configured. Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r--apps/user_ldap/lib/User/User.php8
1 files changed, 5 insertions, 3 deletions
diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php
index 4afc8032f73..f4be19a7ad5 100644
--- a/apps/user_ldap/lib/User/User.php
+++ b/apps/user_ldap/lib/User/User.php
@@ -421,11 +421,13 @@ class User {
if($displayName2 !== '') {
$displayName .= ' (' . $displayName2 . ')';
}
- $oldName = $this->config->getUserValue($this->uid, 'user_ldap', 'displayName', '');
- if ($oldName !== $displayName) {
+ $oldName = $this->config->getUserValue($this->uid, 'user_ldap', 'displayName', null);
+ if ($oldName !== $displayName) {
$this->store('displayName', $displayName);
$user = $this->userManager->get($this->getUsername());
- if ($user instanceof \OC\User\User) {
+ if (!empty($oldName) && $user instanceof \OC\User\User) {
+ // if it was empty, it would be a new record, not a change emitting the trigger could
+ // potentially cause a UniqueConstraintViolationException, depending on some factors.
$user->triggerChange('displayName', $displayName);
}
}