From f22e02cd79e27b1d994fd84a98eb5a8c60563e72 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Thu, 30 Nov 2017 16:00:19 +0100 Subject: Refactor method to check if update is needed There was only one call, that actually needed the parameter to be set to true. So this change moved the print of the page to that location and replaces all other occurences with a direct call to the underlying OCP API. Signed-off-by: Morris Jobke --- lib/base.php | 42 +++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 27 deletions(-) (limited to 'lib/base.php') diff --git a/lib/base.php b/lib/base.php index f6b4f5555eb..89e3e65cea6 100644 --- a/lib/base.php +++ b/lib/base.php @@ -236,7 +236,7 @@ class OC { // Check if config is writable $configFileWritable = is_writable($configFilePath); if (!$configFileWritable && !OC_Helper::isReadOnlyConfigEnabled() - || !$configFileWritable && self::checkUpgrade(false)) { + || !$configFileWritable && \OCP\Util::needUpgrade()) { $urlGenerator = \OC::$server->getURLGenerator(); @@ -289,27 +289,6 @@ class OC { } } - /** - * Checks if the version requires an update and shows - * @param bool $showTemplate Whether an update screen should get shown - * @return bool|void - */ - public static function checkUpgrade($showTemplate = true) { - if (\OCP\Util::needUpgrade()) { - if (function_exists('opcache_reset')) { - opcache_reset(); - } - $systemConfig = \OC::$server->getSystemConfig(); - if ($showTemplate && !$systemConfig->getValue('maintenance', false)) { - self::printUpgradePage(); - exit(); - } else { - return true; - } - } - return false; - } - /** * Prints the upgrade page */ @@ -723,7 +702,7 @@ class OC { ); //setup extra user backends - if (!self::checkUpgrade(false)) { + if (!\OCP\Util::needUpgrade()) { OC_User::setupBackends(); } else { // Run upgrades in incognito mode @@ -806,7 +785,7 @@ class OC { */ public static function registerCleanupHooks() { //don't try to do this before we are properly setup - if (\OC::$server->getSystemConfig()->getValue('installed', false) && !self::checkUpgrade(false)) { + if (\OC::$server->getSystemConfig()->getValue('installed', false) && !\OCP\Util::needUpgrade()) { // NOTE: This will be replaced to use OCP $userSession = self::$server->getUserSession(); @@ -944,7 +923,16 @@ class OC { } if (substr($requestPath, -3) !== '.js') { // we need these files during the upgrade self::checkMaintenanceMode(); - self::checkUpgrade(); + + if (\OCP\Util::needUpgrade()) { + if (function_exists('opcache_reset')) { + opcache_reset(); + } + if (!$systemConfig->getValue('maintenance', false)) { + self::printUpgradePage(); + exit(); + } + } } // emergency app disabling @@ -967,7 +955,7 @@ class OC { OC_App::loadApps(['authentication']); // Load minimum set of apps - if (!self::checkUpgrade(false) + if (!\OCP\Util::needUpgrade() && !$systemConfig->getValue('maintenance', false)) { // For logged-in users: Load everything if(\OC::$server->getUserSession()->isLoggedIn()) { @@ -981,7 +969,7 @@ class OC { if (!self::$CLI) { try { - if (!$systemConfig->getValue('maintenance', false) && !self::checkUpgrade(false)) { + if (!$systemConfig->getValue('maintenance', false) && !\OCP\Util::needUpgrade()) { OC_App::loadApps(array('filesystem', 'logging')); OC_App::loadApps(); } -- cgit v1.2.3 From 0f35ef3727ee6ccec6f80cbc636b45aad00db903 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Thu, 30 Nov 2017 16:01:42 +0100 Subject: Reuse systemconfig Signed-off-by: Morris Jobke --- lib/base.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'lib/base.php') diff --git a/lib/base.php b/lib/base.php index 89e3e65cea6..57e1b0c763f 100644 --- a/lib/base.php +++ b/lib/base.php @@ -291,15 +291,14 @@ class OC { /** * Prints the upgrade page + * + * @param \OC\SystemConfig $systemConfig */ - private static function printUpgradePage() { - $systemConfig = \OC::$server->getSystemConfig(); - + private static function printUpgradePage(\OC\SystemConfig $systemConfig) { $disableWebUpdater = $systemConfig->getValue('upgrade.disable-web', false); $tooBig = false; if (!$disableWebUpdater) { $apps = \OC::$server->getAppManager(); - $tooBig = false; if ($apps->isInstalled('user_ldap')) { $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder(); @@ -903,7 +902,7 @@ class OC { if (!$systemConfig->getValue('installed', false)) { \OC::$server->getSession()->clear(); $setupHelper = new OC\Setup( - \OC::$server->getSystemConfig(), + $systemConfig, \OC::$server->getIniWrapper(), \OC::$server->getL10N('lib'), \OC::$server->query(\OCP\Defaults::class), @@ -929,7 +928,7 @@ class OC { opcache_reset(); } if (!$systemConfig->getValue('maintenance', false)) { - self::printUpgradePage(); + self::printUpgradePage($systemConfig); exit(); } } -- cgit v1.2.3