From e6431cc85c2bc2bbd928dfc69de9cd8921c7e269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Fri, 29 Jul 2016 15:00:18 +0200 Subject: [PATCH 1/2] Ensure the user exists before calling a method on it - fixes #24751 --- lib/private/legacy/util.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php index f0e48349e217..415e38218478 100644 --- a/lib/private/legacy/util.php +++ b/lib/private/legacy/util.php @@ -164,6 +164,7 @@ public static function setupFS($user = '') { // 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]); } @@ -293,12 +294,15 @@ public static function isDefaultExpireDateEnforced() { * @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); } /** From a28c1fb31a5b19725a894251c6ab6f527bb3eaeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Thu, 11 Aug 2016 09:38:06 +0200 Subject: [PATCH 2/2] use $userId instead of $user --- lib/private/legacy/util.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php index 415e38218478..abae20e13711 100644 --- a/lib/private/legacy/util.php +++ b/lib/private/legacy/util.php @@ -290,11 +290,11 @@ public static function isDefaultExpireDateEnforced() { /** * Get the quota of a user * - * @param string $user + * @param string $userId * @return int Quota bytes */ - public static function getUserQuota($user) { - $user = \OC::$server->getUserManager()->get($user); + public static function getUserQuota($userId) { + $user = \OC::$server->getUserManager()->get($userId); if (is_null($user)) { return \OCP\Files\FileInfo::SPACE_UNLIMITED; }