From: Thomas Müller Date: Fri, 29 Jul 2016 13:00:18 +0000 (+0200) Subject: Ensure the user exists before calling a method on it - fixes #24751 X-Git-Tag: v11.0RC2~827^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=26342061b9b9767577a0f5eee16afd36e3b8b0b1;p=nextcloud-server.git Ensure the user exists before calling a method on it - fixes #24751 --- diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php index 83274f82792..cea7847b3d3 100644 --- a/lib/private/legacy/util.php +++ b/lib/private/legacy/util.php @@ -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); } /**