Ensure the user exists before calling a method on it - fixes #24751

This commit is contained in:
Thomas Müller 2016-07-29 15:00:18 +02:00 committed by Roeland Jago Douma
parent 582250e55c
commit 63fc5b601d
No known key found for this signature in database
GPG Key ID: 1E152838F164D13B
1 changed files with 7 additions and 3 deletions

View File

@ -165,6 +165,7 @@ class OC_Util {
// 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]);
}
@ -294,12 +295,15 @@ class OC_Util {
* @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;
}
$userQuota = $user->getQuota();
if($userQuota === 'none') {
return \OCP\Files\FileInfo::SPACE_UNLIMITED;
}else{
return OC_Helper::computerFileSize($userQuota);
}
return OC_Helper::computerFileSize($userQuota);
}
/**