]> source.dussan.org Git - nextcloud-server.git/commitdiff
Check if the user exists before trying to set the quota
authorJuan Pablo Villafáñez <jvillafanez@solidgear.es>
Tue, 14 Mar 2017 16:08:05 +0000 (17:08 +0100)
committerArthur Schiwon <blizzz@arthur-schiwon.de>
Wed, 29 Mar 2017 11:32:16 +0000 (13:32 +0200)
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
apps/user_ldap/lib/User/User.php

index 7a840de87f64220676712e3d321bdc5db51c083f..392cb2e51ba96e763b6e30eedee57ed97854bb12 100644 (file)
@@ -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);
                }
        }