Skip to content

Commit

Permalink
Ensure the user exists before calling a method on it - fixes #24751
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepDiver1975 committed Jul 29, 2016
1 parent 4374b46 commit e6431cc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/private/legacy/util.php
Expand Up @@ -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]);
}
Expand Down Expand Up @@ -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;
}

This comment has been minimized.

Copy link
@dragotin

dragotin Aug 2, 2016

Contributor

If the user is not valid why return unlimited space? Wouldn't it be better to return zero?

$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

0 comments on commit e6431cc

Please sign in to comment.