From ef8da70d94ea7618d94e3785ed6e98729d13c951 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Thu, 11 Aug 2016 19:45:19 +0200 Subject: [PATCH] [stable9] Merge pull request #25652 from owncloud/fix-getQuota-on-null Ensure the user exists before calling a method on it --- lib/private/util.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/private/util.php b/lib/private/util.php index d53a6ca9864e..8ff3db72cf93 100644 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -282,16 +282,19 @@ 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) { - $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); } /**