Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure the user exists before calling a method on it #25652

Merged
merged 2 commits into from
Aug 11, 2016
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
14 changes: 9 additions & 5 deletions lib/private/legacy/util.php
Original file line number Diff line number Diff line change
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 @@ -289,16 +290,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