From f9832ff3475a1feec9d8b8d2d42bbf56d72c0118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Pablo=20Villaf=C3=A1=C3=B1ez?= Date: Tue, 14 Mar 2017 17:08:05 +0100 Subject: [PATCH] Check if the user exists before trying to set the quota Signed-off-by: Arthur Schiwon --- apps/user_ldap/lib/User/User.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php index 7a840de87f..392cb2e51b 100644 --- a/apps/user_ldap/lib/User/User.php +++ b/apps/user_ldap/lib/User/User.php @@ -498,11 +498,16 @@ class User { } } - if($quota !== false) { - $this->userManager->get($this->uid)->setQuota($quota); + $targetUser = $this->userManager->get($this->uid); + if ($targetUser) { + if($quota !== false) { + $targetUser->setQuota($quota); + } else { + $this->log->log('not suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', \OCP\Util::WARN); + $targetUser->setQuota('default'); + } } else { - $this->log->log('not suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', \OCP\Util::WARN); - $this->userManager->get($this->uid)->setQuota('default'); + $this->log->log('trying to set a quota for user ' . $this->uid . ' but the user is missing', \OCP\Util::ERROR); } }