diff --git a/config/config.sample.php b/config/config.sample.php index f05b206957..7778d4f6d6 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -1196,6 +1196,11 @@ $CONFIG = array( */ 'memcache.locking' => '\\OC\\Memcache\\Redis', +/** + * Disable the web based updater + */ +'upgrade.disable-web' => false, + /** * Set this ownCloud instance to debugging mode * diff --git a/core/ajax/update.php b/core/ajax/update.php index 631a8a7871..cf6e265951 100644 --- a/core/ajax/update.php +++ b/core/ajax/update.php @@ -37,9 +37,17 @@ $eventSource = \OC::$server->createEventSource(); // need to send an initial message to force-init the event source, // which will then trigger its own CSRF check and produces its own CSRF error // message -$eventSource->send('success', (string)$l->t('Preparing update')); +//$eventSource->send('success', (string)$l->t('Preparing update')); if (OC::checkUpgrade(false)) { + + $config = \OC::$server->getSystemConfig(); + if ($config->getValue('upgrade.disable-web', true)) { + $eventSource->send('failure', (string)$l->t('Updates need to be installed. Please use the command line updater.')); + $eventSource->close(); + exit(); + } + // if a user is currently logged in, their session must be ignored to // avoid side effects \OC_User::setIncognitoMode(true); diff --git a/core/templates/update.use-cli.php b/core/templates/update.use-cli.php new file mode 100644 index 0000000000..52d40cdea5 --- /dev/null +++ b/core/templates/update.use-cli.php @@ -0,0 +1,14 @@ +
+
+

t('Update needed')) ?>

+
+ t('Please use the command line updater because you have a big instance.')); + } else { + p($l->t('Please use the command line updater because automatic updating is disabled in the config.php.')); + } ?>

+ t('For help, see the documentation.', [link_to_docs('admin-cli-upgrade')])); ?>

+
+
+
diff --git a/lib/base.php b/lib/base.php index 818e13fbef..2796758836 100644 --- a/lib/base.php +++ b/lib/base.php @@ -337,27 +337,49 @@ class OC { */ private static function printUpgradePage() { $systemConfig = \OC::$server->getSystemConfig(); + + $disableWebUpdater = $systemConfig->getValue('upgrade.disable-web', false); + $tooBig = false; + if (!$disableWebUpdater) { + // count users + $stats = \OC::$server->getUserManager()->countUsers(); + $totalUsers = array_sum($stats); + $tooBig = ($totalUsers > 50); + } + if ($disableWebUpdater || $tooBig) { + // send http status 503 + header('HTTP/1.1 503 Service Temporarily Unavailable'); + header('Status: 503 Service Temporarily Unavailable'); + header('Retry-After: 120'); + + // render error page + $template = new OC_Template('', 'update.use-cli', 'guest'); + $template->assign('productName', 'ownCloud'); // for now + $template->assign('version', OC_Util::getVersionString()); + $template->assign('tooBig', $tooBig); + + $template->printPage(); + die(); + } + + // check whether this is a core update or apps update + $installedVersion = $systemConfig->getValue('version', '0.0.0'); + $currentVersion = implode('.', \OCP\Util::getVersion()); + + // if not a core upgrade, then it's apps upgrade + $isAppsOnlyUpgrade = (version_compare($currentVersion, $installedVersion, '=')); + $oldTheme = $systemConfig->getValue('theme'); $systemConfig->setValue('theme', ''); \OCP\Util::addScript('config'); // needed for web root \OCP\Util::addScript('update'); \OCP\Util::addStyle('update'); - // check whether this is a core update or apps update - $installedVersion = $systemConfig->getValue('version', '0.0.0'); - $currentVersion = implode('.', \OCP\Util::getVersion()); - $appManager = \OC::$server->getAppManager(); $tmpl = new OC_Template('', 'update.admin', 'guest'); $tmpl->assign('version', OC_Util::getVersionString()); - - // if not a core upgrade, then it's apps upgrade - if (version_compare($currentVersion, $installedVersion, '=')) { - $tmpl->assign('isAppsOnlyUpgrade', true); - } else { - $tmpl->assign('isAppsOnlyUpgrade', false); - } + $tmpl->assign('isAppsOnlyUpgrade', $isAppsOnlyUpgrade); // get third party apps $ocVersion = \OCP\Util::getVersion(); @@ -423,7 +445,7 @@ class OC { } public static function loadAppClassPaths() { - foreach (OC_APP::getEnabledApps() as $app) { + foreach (OC_App::getEnabledApps() as $app) { $appPath = OC_App::getAppPath($app); if ($appPath === false) { continue;