diff options
author | Joas Schilling <coding@schilljs.com> | 2016-08-16 12:57:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-16 12:57:34 +0200 |
commit | f7bc5ad43b9cee9befa317d251446bc4e5e81f9c (patch) | |
tree | 8153b802e85710b657c178af01d9a2468aa9a466 /lib | |
parent | 6dc956b1923fbb4071d481f32e6fc8d32fd41ed2 (diff) | |
parent | 264aaf9ffaf71b2fc8a6bd2f5d5c9bf4a6d403de (diff) | |
download | nextcloud-server-f7bc5ad43b9cee9befa317d251446bc4e5e81f9c.tar.gz nextcloud-server-f7bc5ad43b9cee9befa317d251446bc4e5e81f9c.zip |
Merge pull request #864 from nextcloud/us_25652
[us] 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 83274f82792..a31d02dc01e 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]); } @@ -290,16 +291,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); } /** |