summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-04-11 16:58:08 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2016-04-18 17:09:21 +0200
commit739dfb5c6638301799ee8dafd6b10460b493319d (patch)
tree1bb734784ec8ca83653068f21d59e0a27d0f6323
parentfd1740deb604894a8bef515d98c5992a392e6f0a (diff)
downloadnextcloud-server-739dfb5c6638301799ee8dafd6b10460b493319d.tar.gz
nextcloud-server-739dfb5c6638301799ee8dafd6b10460b493319d.zip
Suggest cli based updater in case the instance is bigger - #23913
-rw-r--r--config/config.sample.php5
-rw-r--r--core/ajax/update.php10
-rw-r--r--core/templates/update.use-cli.php14
-rw-r--r--lib/base.php46
4 files changed, 62 insertions, 13 deletions
diff --git a/config/config.sample.php b/config/config.sample.php
index f05b206957a..7778d4f6d65 100644
--- a/config/config.sample.php
+++ b/config/config.sample.php
@@ -1197,6 +1197,11 @@ $CONFIG = array(
'memcache.locking' => '\\OC\\Memcache\\Redis',
/**
+ * Disable the web based updater
+ */
+'upgrade.disable-web' => false,
+
+/**
* Set this ownCloud instance to debugging mode
*
* Only enable this for local development and not in production environments
diff --git a/core/ajax/update.php b/core/ajax/update.php
index 631a8a7871c..cf6e2659516 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 00000000000..52d40cdea55
--- /dev/null
+++ b/core/templates/update.use-cli.php
@@ -0,0 +1,14 @@
+<div class="update" data-productname="<?php p($_['productName']) ?>" data-version="<?php p($_['version']) ?>">
+ <div class="updateOverview">
+ <h2 class="title"><?php p($l->t('Update needed')) ?></h2>
+ <div class="infogroup">
+ <?php if ($_['tooBig']) {
+ p($l->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.'));
+ } ?><br><br>
+ <?php
+ print_unescaped($l->t('For help, see the <a target="_blank" rel="noreferrer" href="%s">documentation</a>.', [link_to_docs('admin-cli-upgrade')])); ?><br><br>
+ </div>
+ </div>
+</div>
diff --git a/lib/base.php b/lib/base.php
index 818e13fbef2..27967588360 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;