diff --git a/lib/base.php b/lib/base.php index a4b5e9e01bf1..512bcfe664a5 100644 --- a/lib/base.php +++ b/lib/base.php @@ -237,7 +237,7 @@ public static function checkConfig() { // Check if config is writable $configFileWritable = is_writable($configFilePath); if (!$configFileWritable && !OC_Helper::isReadOnlyConfigEnabled() - || !$configFileWritable && \OCP\Util::needUpgrade()) { + || !$configFileWritable && self::checkUpgrade(false)) { if (self::$CLI) { echo $l->t('Cannot write into "config" directory!')."\n"; echo $l->t('This can usually be fixed by giving the webserver write access to the config directory')."\n"; @@ -741,7 +741,7 @@ private static function registerLocalAddressBook() { */ public static function registerCacheHooks() { //don't try to do this before we are properly setup - if (\OC::$server->getSystemConfig()->getValue('installed', false) && !\OCP\Util::needUpgrade()) { + if (\OC::$server->getSystemConfig()->getValue('installed', false) && !self::checkUpgrade(false)) { // NOTE: This will be replaced to use OCP $userSession = self::$server->getUserSession(); @@ -777,7 +777,7 @@ private static function registerEncryptionHooks() { */ public static function registerLogRotate() { $systemConfig = \OC::$server->getSystemConfig(); - if ($systemConfig->getValue('installed', false) && $systemConfig->getValue('log_rotate_size', false) && !\OCP\Util::needUpgrade()) { + if ($systemConfig->getValue('installed', false) && $systemConfig->getValue('log_rotate_size', false) && !self::checkUpgrade(false)) { //don't try to do this before we are properly setup //use custom logfile path if defined, otherwise use default of owncloud.log in data directory \OCP\BackgroundJob::registerJob('OC\Log\Rotate', $systemConfig->getValue('logfile', $systemConfig->getValue('datadirectory', OC::$SERVERROOT . '/data') . '/owncloud.log')); @@ -869,8 +869,7 @@ public static function handleRequest() { // Load minimum set of apps if (!self::checkUpgrade(false) - && !$systemConfig->getValue('maintenance', false) - && !\OCP\Util::needUpgrade()) { + && !$systemConfig->getValue('maintenance', false)) { // For logged-in users: Load everything if(OC_User::isLoggedIn()) { OC_App::loadApps(); @@ -883,7 +882,7 @@ public static function handleRequest() { if (!self::$CLI and (!isset($_GET["logout"]) or ($_GET["logout"] !== 'true'))) { try { - if (!$systemConfig->getValue('maintenance', false) && !\OCP\Util::needUpgrade()) { + if (!$systemConfig->getValue('maintenance', false) && !self::checkUpgrade(false)) { OC_App::loadApps(array('filesystem', 'logging')); OC_App::loadApps(); } diff --git a/lib/public/util.php b/lib/public/util.php index c32668b14a86..4b0d95643888 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -661,6 +661,7 @@ public static function isDefaultExpireDateEnforced() { return \OC_Util::isDefaultExpireDateEnforced(); } + protected static $needUpgrade = null; /** * Checks whether the current version needs upgrade. @@ -669,6 +670,9 @@ public static function isDefaultExpireDateEnforced() { * @since 7.0.0 */ public static function needUpgrade() { - return \OC_Util::needUpgrade(\OC::$server->getConfig()); + if (!isset(self::$needUpgrade)) { + self::$needUpgrade=\OC_Util::needUpgrade(\OC::$server->getConfig()); + } + return self::$needUpgrade; } }