]> source.dussan.org Git - nextcloud-server.git/commitdiff
Ensure the user exists before calling a method on it - fixes #24751
authorThomas Müller <thomas.mueller@tmit.eu>
Fri, 29 Jul 2016 13:00:18 +0000 (15:00 +0200)
committerRoeland Jago Douma <roeland@famdouma.nl>
Wed, 17 Aug 2016 13:51:19 +0000 (15:51 +0200)
lib/private/legacy/util.php

index 83274f82792967a22dbad5deee6d5557922aa500..cea7847b3d3f877d01c8156043b3a4ac7691de6d 100644 (file)
@@ -165,6 +165,7 @@ class OC_Util {
 
                // install storage availability wrapper, before most other wrappers
                \OC\Files\Filesystem::addStorageWrapper('oc_availability', function ($mountPoint, $storage) {
+                       /** @var \OCP\Files\Storage $storage */
                        if (!$storage->instanceOfStorage('\OC\Files\Storage\Shared') && !$storage->isLocal()) {
                                return new \OC\Files\Storage\Wrapper\Availability(['storage' => $storage]);
                        }
@@ -294,12 +295,15 @@ class OC_Util {
         * @return int Quota bytes
         */
        public static function getUserQuota($user) {
-               $userQuota = \OC::$server->getUserManager()->get($user)->getQuota();
+               $user = \OC::$server->getUserManager()->get($user);
+               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);
        }
 
        /**