Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[stable9] Merge pull request #25652 from owncloud/fix-getQuota-on-null
Ensure the user exists before calling a method on it
  • Loading branch information
Vincent Petry committed Aug 16, 2016
commit ef8da70d94ea7618d94e3785ed6e98729d13c951
13 changes: 8 additions & 5 deletions lib/private/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down