Skip to content

Commit

Permalink
Merge pull request #911 from nextcloud/stable9_864
Browse files Browse the repository at this point in the history
[Stable9] Ensure the user exists before calling a method on it
  • Loading branch information
nickvergessen authored Aug 18, 2016
2 parents edf08f5 + aed78c2 commit 2d025db
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/private/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,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 @@ -283,16 +284,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();
if($userQuota === 'none') {
public static function getUserQuota($userId) {
$user = \OC::$server->getUserManager()->get($userId);
if (is_null($user)) {
return \OCP\Files\FileInfo::SPACE_UNLIMITED;
}else{
return OC_Helper::computerFileSize($userQuota);
}
$userQuota = $user->getQuota();
if($userQuota === 'none') {
return \OCP\Files\FileInfo::SPACE_UNLIMITED;
}
return OC_Helper::computerFileSize($userQuota);
}

/**
Expand Down

0 comments on commit 2d025db

Please sign in to comment.