diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-08-11 20:45:19 +0300 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-08-11 20:51:31 +0300 |
commit | befed183e501ef0776cccd3f9ce907fc3dc15ee6 (patch) | |
tree | 0c26bb5c19e7ff714c125838893e57761959a51c /lib | |
parent | 912aa4f82b0da2a05168091e78225b03b800ed1f (diff) |
[stable9.1] Merge pull request #25652 from owncloud/fix-getQuota-on-null
Ensure the user exists before calling a method on it
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/legacy/util.php | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php index f34fef7d06d..06cd1bee4ce 100644 --- a/lib/private/legacy/util.php +++ b/lib/private/legacy/util.php @@ -164,6 +164,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]); } @@ -289,16 +290,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); } /** |