]> source.dussan.org Git - nextcloud-server.git/commitdiff
Make sure maintenance mode is always casted to bool
authorJoas Schilling <coding@schilljs.com>
Wed, 6 Feb 2019 16:08:41 +0000 (17:08 +0100)
committerJoas Schilling <coding@schilljs.com>
Fri, 22 Feb 2019 07:25:41 +0000 (08:25 +0100)
Signed-off-by: Joas Schilling <coding@schilljs.com>
14 files changed:
apps/dav/lib/Connector/Sabre/MaintenancePlugin.php
apps/encryption/lib/AppInfo/Application.php
core/Command/Encryption/DecryptAll.php
core/Command/Encryption/EncryptAll.php
core/Command/Maintenance/Mode.php
core/Command/Maintenance/Repair.php
core/Command/Upgrade.php
cron.php
lib/base.php
lib/private/Console/Application.php
lib/private/Route/Router.php
lib/private/Updater.php
lib/private/legacy/app.php
ocs/v1.php

index 36110c81db925f61a7a471c4be16896a831524ae..9c5946481b65ac9336c2b28e201b2d26a7baf1b7 100644 (file)
@@ -78,7 +78,7 @@ class MaintenancePlugin extends ServerPlugin {
         * @return bool
         */
        public function checkMaintenanceMode() {
-               if ($this->config->getSystemValue('maintenance', false)) {
+               if ($this->config->getSystemValueBool('maintenance')) {
                        throw new ServiceUnavailable('System in maintenance mode.');
                }
                if (Util::needUpgrade()) {
index 55839e097a1b41da831fbad7faa094a519d97431..5846a01db13959c134c7c17ab54a6097a52e8000 100644 (file)
@@ -75,7 +75,7 @@ class Application extends \OCP\AppFramework\App {
         * register hooks
         */
        public function registerHooks() {
-               if (!$this->config->getSystemValue('maintenance', false)) {
+               if (!$this->config->getSystemValueBool('maintenance')) {
 
                        $container = $this->getContainer();
                        $server = $container->getServer();
index 253223f95295e1e31d49808fdea292d687566387..6ae90196963234ce5e8ac8fcb0b926ea2f60a21d 100644 (file)
@@ -89,7 +89,7 @@ class DecryptAll extends Command {
         */
        protected function forceMaintenanceAndTrashbin() {
                $this->wasTrashbinEnabled = $this->appManager->isEnabledForUser('files_trashbin');
-               $this->wasMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false);
+               $this->wasMaintenanceModeEnabled = $this->config->getSystemValueBool('maintenance');
                $this->config->setSystemValue('maintenance', true);
                $this->appManager->disableApp('files_trashbin');
        }
index b16fa0af2c780f239ed084d317006fa6dfb1279d..7a257aac201b2ae36728438aa7c6ddb79945cc26 100644 (file)
@@ -78,7 +78,7 @@ class EncryptAll extends Command {
         */
        protected function forceMaintenanceAndTrashbin() {
                $this->wasTrashbinEnabled = $this->appManager->isEnabledForUser('files_trashbin');
-               $this->wasMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false);
+               $this->wasMaintenanceModeEnabled = $this->config->getSystemValueBool('maintenance');
                $this->config->setSystemValue('maintenance', true);
                $this->appManager->disableApp('files_trashbin');
        }
index db4c9dc8c0b293b09cdc46b56b51089fbff8de9c..1692eb08d87cfa39c6d9ce2668c884557ec26c6c 100644 (file)
@@ -59,7 +59,7 @@ class Mode extends Command {
        }
 
        protected function execute(InputInterface $input, OutputInterface $output) {
-               $maintenanceMode = $this->config->getSystemValue('maintenance', false);
+               $maintenanceMode = $this->config->getSystemValueBool('maintenance');
                if ($input->getOption('on')) {
                        if ($maintenanceMode === false) {
                                $this->config->setSystemValue('maintenance', true);
index e9595a222850e8c16bfb7096dd842472c0b1fc73..460bc6880c15bdae5173683cc538211ba8b53f45 100644 (file)
@@ -106,7 +106,7 @@ class Repair extends Command {
                        }
                }
 
-               $maintenanceMode = $this->config->getSystemValue('maintenance', false);
+               $maintenanceMode = $this->config->getSystemValueBool('maintenance');
                $this->config->setSystemValue('maintenance', true);
 
                $this->progress = new ProgressBar($output);
index 5a2deea0b6cbb0fa13047218e59e4cf6589c22f7..2d7ec4f688d11a5223a697cbf596af6f28c37bf9 100644 (file)
@@ -180,7 +180,7 @@ class Upgrade extends Command {
                        $dispatcher->addListener('\OC\Repair::info', $repairListener);
                        $dispatcher->addListener('\OC\Repair::warning', $repairListener);
                        $dispatcher->addListener('\OC\Repair::error', $repairListener);
-                       
+
 
                        $updater->listen('\OC\Updater', 'maintenanceEnabled', function () use($output) {
                                $output->writeln('<info>Turned on maintenance mode</info>');
@@ -264,7 +264,7 @@ class Upgrade extends Command {
                        }
 
                        return self::ERROR_SUCCESS;
-               } else if($this->config->getSystemValue('maintenance', false)) {
+               } else if($this->config->getSystemValueBool('maintenance')) {
                        //Possible scenario: Nextcloud core is updated but an app failed
                        $output->writeln('<warning>Nextcloud is in maintenance mode</warning>');
                        $output->write('<comment>Maybe an upgrade is already in process. Please check the '
index b79c40d2a72e16943b5d7364a5c3918404b7d258..cdfa0fb367de0878239455c8e3e9d6722b5cb9d4 100644 (file)
--- a/cron.php
+++ b/cron.php
@@ -44,7 +44,7 @@ try {
                \OC::$server->getLogger()->debug('Update required, skipping cron', ['app' => 'cron']);
                exit;
        }
-       if (\OC::$server->getSystemConfig()->getValue('maintenance', false)) {
+       if ((bool) \OC::$server->getSystemConfig()->getValue('maintenance', false)) {
                \OC::$server->getLogger()->debug('We are in maintenance mode, skipping cron', ['app' => 'cron']);
                exit;
        }
index 90fa5496200e9f6e70fd2e8748396d1fcb165707..d5149fc0449dda347335b2d079a738f1bb66aac3 100644 (file)
@@ -285,7 +285,7 @@ class OC {
 
        public static function checkMaintenanceMode() {
                // Allow ajax update script to execute without being stopped
-               if (\OC::$server->getSystemConfig()->getValue('maintenance', false) && OC::$SUBURI != '/core/ajax/update.php') {
+               if (((bool) \OC::$server->getSystemConfig()->getValue('maintenance', false)) && OC::$SUBURI != '/core/ajax/update.php') {
                        // send http status 503
                        http_response_code(503);
                        header('Retry-After: 120');
@@ -938,7 +938,7 @@ class OC {
                                if (function_exists('opcache_reset')) {
                                        opcache_reset();
                                }
-                               if (!$systemConfig->getValue('maintenance', false)) {
+                               if (!((bool) $systemConfig->getValue('maintenance', false))) {
                                        self::printUpgradePage($systemConfig);
                                        exit();
                                }
@@ -966,7 +966,7 @@ class OC {
 
                // Load minimum set of apps
                if (!\OCP\Util::needUpgrade()
-                       && !$systemConfig->getValue('maintenance', false)) {
+                       && !((bool) $systemConfig->getValue('maintenance', false))) {
                        // For logged-in users: Load everything
                        if(\OC::$server->getUserSession()->isLoggedIn()) {
                                OC_App::loadApps();
@@ -979,7 +979,7 @@ class OC {
 
                if (!self::$CLI) {
                        try {
-                               if (!$systemConfig->getValue('maintenance', false) && !\OCP\Util::needUpgrade()) {
+                               if (!((bool) $systemConfig->getValue('maintenance', false)) && !\OCP\Util::needUpgrade()) {
                                        OC_App::loadApps(array('filesystem', 'logging'));
                                        OC_App::loadApps();
                                }
index 0e30fa02b94d3a939c720e9073348910a6d6ecc3..d7c047527f18b794bea4367fe1e4d101635e9ba4 100644 (file)
@@ -91,10 +91,10 @@ class Application {
                $inputDefinition = $application->getDefinition();
                $inputDefinition->addOption(
                        new InputOption(
-                               'no-warnings', 
-                               null, 
-                               InputOption::VALUE_NONE, 
-                               'Skip global warnings, show command output only', 
+                               'no-warnings',
+                               null,
+                               InputOption::VALUE_NONE,
+                               'Skip global warnings, show command output only',
                                null
                        )
                );
@@ -119,7 +119,7 @@ class Application {
                        if ($this->config->getSystemValue('installed', false)) {
                                if (\OCP\Util::needUpgrade()) {
                                        throw new NeedsUpdateException();
-                               } elseif ($this->config->getSystemValue('maintenance', false)) {
+                               } elseif ($this->config->getSystemValueBool('maintenance')) {
                                        $this->writeMaintenanceModeInfo($input, $output);
                                } else {
                                        OC_App::loadApps();
index b44b3f7c2cec2c6ca88313fb0c1f10d61e6c83a9..1839b356424f7532a6d17baabc69b9259a1c0f26 100644 (file)
@@ -260,7 +260,7 @@ class Router implements IRouter {
                        $this->loadRoutes($app);
                } else if (substr($url, 0, 6) === '/core/' or substr($url, 0, 10) === '/settings/') {
                        \OC::$REQUESTEDAPP = $url;
-                       if (!\OC::$server->getConfig()->getSystemValue('maintenance', false) && !Util::needUpgrade()) {
+                       if (!\OC::$server->getConfig()->getSystemValueBool('maintenance') && !Util::needUpgrade()) {
                                \OC_App::loadApps();
                        }
                        $this->loadRoutes('core');
index 4b4723be94fd8c25d36a966c1f515a6495ac0caf..313cfc82ffac0376987a756e98b40c24ce924891 100644 (file)
@@ -104,7 +104,7 @@ class Updater extends BasicEmitter {
                $this->emit('\OC\Updater', 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]);
                $this->config->setSystemValue('loglevel', ILogger::DEBUG);
 
-               $wasMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false);
+               $wasMaintenanceModeEnabled = $this->config->getSystemValueBool('maintenance');
 
                if(!$wasMaintenanceModeEnabled) {
                        $this->config->setSystemValue('maintenance', true);
@@ -614,4 +614,3 @@ class Updater extends BasicEmitter {
        }
 
 }
-
index 4cab92eba64596449483893cf7a060f4c0482cd2..9b4a83de3491f66c040771859ed22560a0926237 100644 (file)
@@ -106,7 +106,7 @@ class OC_App {
         * if $types is set to non-empty array, only apps of those types will be loaded
         */
        public static function loadApps(array $types = []): bool {
-               if (\OC::$server->getSystemConfig()->getValue('maintenance', false)) {
+               if ((bool) \OC::$server->getSystemConfig()->getValue('maintenance', false)) {
                        return false;
                }
                // Load the enabled apps here
index 36749f44c1b50b7b2faaa7ee0e239870c4c6e3c9..4e50392e7522508033b4a58b910af6f35fba42b0 100644 (file)
@@ -33,7 +33,7 @@ require_once __DIR__ . '/../lib/versioncheck.php';
 require_once __DIR__ . '/../lib/base.php';
 
 if (\OCP\Util::needUpgrade()
-       || \OC::$server->getSystemConfig()->getValue('maintenance', false)) {
+       || \OC::$server->getConfig()->getSystemValueBool('maintenance')) {
        // since the behavior of apps or remotes are unpredictable during
        // an upgrade, return a 503 directly
        http_response_code(503);
@@ -103,4 +103,3 @@ try {
                .' http://www.freedesktop.org/wiki/Specifications/open-collaboration-services.'."\n";
        OC_API::respond(new \OC\OCS\Result(null, \OCP\API::RESPOND_NOT_FOUND, $txt), $format);
 }
-