Suggest cli based updater in case the instance is bigger - #23913

This commit is contained in:
Thomas Müller 2016-04-11 16:58:08 +02:00
parent fd1740deb6
commit 739dfb5c66
No known key found for this signature in database
GPG Key ID: A943788A3BBEC44C
4 changed files with 62 additions and 13 deletions

View File

@ -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
*

View File

@ -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);

View File

@ -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>

View File

@ -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;