diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-11-30 16:00:19 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2017-11-30 16:04:07 +0100 |
commit | f22e02cd79e27b1d994fd84a98eb5a8c60563e72 (patch) | |
tree | ed473f4d77fcbb8b1be958c1e29f5fee72336ecb | |
parent | 288f50bdc72011ce4e045322698793a843e09b0a (diff) | |
download | nextcloud-server-f22e02cd79e27b1d994fd84a98eb5a8c60563e72.tar.gz nextcloud-server-f22e02cd79e27b1d994fd84a98eb5a8c60563e72.zip |
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 <hey@morrisjobke.de>
-rw-r--r-- | apps/dav/lib/Connector/Sabre/MaintenancePlugin.php | 3 | ||||
-rw-r--r-- | core/Command/Upgrade.php | 3 | ||||
-rw-r--r-- | core/ajax/update.php | 2 | ||||
-rw-r--r-- | lib/base.php | 42 |
4 files changed, 20 insertions, 30 deletions
diff --git a/apps/dav/lib/Connector/Sabre/MaintenancePlugin.php b/apps/dav/lib/Connector/Sabre/MaintenancePlugin.php index 21bffcdb299..36110c81db9 100644 --- a/apps/dav/lib/Connector/Sabre/MaintenancePlugin.php +++ b/apps/dav/lib/Connector/Sabre/MaintenancePlugin.php @@ -27,6 +27,7 @@ namespace OCA\DAV\Connector\Sabre; use OCP\IConfig; +use OCP\Util; use Sabre\DAV\Exception\ServiceUnavailable; use Sabre\DAV\ServerPlugin; @@ -80,7 +81,7 @@ class MaintenancePlugin extends ServerPlugin { if ($this->config->getSystemValue('maintenance', false)) { throw new ServiceUnavailable('System in maintenance mode.'); } - if (\OC::checkUpgrade(false)) { + if (Util::needUpgrade()) { throw new ServiceUnavailable('Upgrade needed'); } diff --git a/core/Command/Upgrade.php b/core/Command/Upgrade.php index 2a502dbe921..c60e6da0795 100644 --- a/core/Command/Upgrade.php +++ b/core/Command/Upgrade.php @@ -39,6 +39,7 @@ use OC\Installer; use OC\Updater; use OCP\IConfig; use OCP\ILogger; +use OCP\Util; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Input\InputInterface; @@ -93,7 +94,7 @@ class Upgrade extends Command { */ protected function execute(InputInterface $input, OutputInterface $output) { - if(\OC::checkUpgrade(false)) { + if(Util::needUpgrade()) { if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { // Prepend each line with a little timestamp $timestampFormatter = new TimestampFormatter($this->config, $output->getFormatter()); diff --git a/core/ajax/update.php b/core/ajax/update.php index 2a29d1e536c..839f5f3679f 100644 --- a/core/ajax/update.php +++ b/core/ajax/update.php @@ -98,7 +98,7 @@ class FeedBackHandler { } } -if (OC::checkUpgrade(false)) { +if (\OCP\Util::needUpgrade()) { $config = \OC::$server->getSystemConfig(); if ($config->getValue('upgrade.disable-web', false)) { 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(); @@ -290,27 +290,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 */ private static function printUpgradePage() { @@ -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(); } |