]> source.dussan.org Git - nextcloud-server.git/commitdiff
[stable9] Merge pull request #25652 from owncloud/fix-getQuota-on-null
authorVincent Petry <pvince81@owncloud.com>
Thu, 11 Aug 2016 17:45:19 +0000 (19:45 +0200)
committerVincent Petry <pvince81@owncloud.com>
Tue, 16 Aug 2016 15:18:45 +0000 (17:18 +0200)
Ensure the user exists before calling a method on it

lib/private/util.php

index d53a6ca9864ebfa1550535aba13b69f0bbf3c73c..8ff3db72cf9383fadfa513cbe3ca8d704c5cb2f1 100644 (file)
@@ -282,16 +282,19 @@ class OC_Util {
        /**
         * Get the quota of a user
         *
-        * @param string $user
+        * @param string $userId
         * @return int Quota bytes
         */
-       public static function getUserQuota($user) {
-               $userQuota = \OC::$server->getUserManager()->get($user)->getQuota();
+       public static function getUserQuota($userId) {
+               $user = \OC::$server->getUserManager()->get($userId);
+               if (is_null($user)) {
+                       return \OCP\Files\FileInfo::SPACE_UNLIMITED;
+               }
+               $userQuota = $user->getQuota();
                if($userQuota === 'none') {
                        return \OCP\Files\FileInfo::SPACE_UNLIMITED;
-               }else{
-                       return OC_Helper::computerFileSize($userQuota);
                }
+               return OC_Helper::computerFileSize($userQuota);
        }
 
        /**