diff options
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/app.php | 31 | ||||
-rwxr-xr-x | lib/private/util.php | 16 |
2 files changed, 34 insertions, 13 deletions
diff --git a/lib/private/app.php b/lib/private/app.php index d10d352b432..3eed9e3c443 100644 --- a/lib/private/app.php +++ b/lib/private/app.php @@ -172,17 +172,29 @@ class OC_App { */ protected static $enabledAppsCache = array(); - public static function getEnabledApps($forceRefresh = false) { + /** + * Returns apps enabled for the current user. + * + * @param bool $forceRefresh whether to refresh the cache + * @param bool $all whether to return apps for all users, not only the + * currently logged in one + */ + public static function getEnabledApps($forceRefresh = false, $all = false) { if (!OC_Config::getValue('installed', false)) { return array(); } - if (!$forceRefresh && !empty(self::$enabledAppsCache)) { + // in incognito mode or when logged out, $user will be false, + // which is also the case during an upgrade + $user = null; + if (!$all) { + $user = \OC_User::getUser(); + } + if (is_string($user) && !$forceRefresh && !empty(self::$enabledAppsCache)) { return self::$enabledAppsCache; } $apps = array(); $appConfig = \OC::$server->getAppConfig(); $appStatus = $appConfig->getValues(false, 'enabled'); - $user = \OC_User::getUser(); foreach ($appStatus as $app => $enabled) { if ($app === 'files') { continue; @@ -192,11 +204,16 @@ class OC_App { } else if ($enabled !== 'no') { $groups = json_decode($enabled); if (is_array($groups)) { - foreach ($groups as $group) { - if (\OC_Group::inGroup($user, $group)) { - $apps[] = $app; - break; + if (is_string($user)) { + foreach ($groups as $group) { + if (\OC_Group::inGroup($user, $group)) { + $apps[] = $app; + break; + } } + } else { + // global, consider app as enabled + $apps[] = $app; } } } diff --git a/lib/private/util.php b/lib/private/util.php index adb7fb83d28..d690880f987 100755 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -1490,9 +1490,11 @@ class OC_Util { } /** - * Check whether the instance needs to preform an upgrade + * Check whether the instance needs to perform an upgrade, + * either when the core version is higher or any app requires + * an upgrade. * - * @return bool + * @return bool whether the core or any app needs an upgrade */ public static function needUpgrade() { if (OC_Config::getValue('installed', false)) { @@ -1502,14 +1504,16 @@ class OC_Util { return true; } - // also check for upgrades for apps - $apps = \OC_App::getEnabledApps(); + // also check for upgrades for apps (independently from the user) + $apps = \OC_App::getEnabledApps(false, true); + $shouldUpgrade = false; foreach ($apps as $app) { if (\OC_App::shouldUpgrade($app)) { - return true; + $shouldUpgrade = true; + break; } } - return false; + return $shouldUpgrade; } else { return false; } |