diff --git a/core/ajax/update.php b/core/ajax/update.php deleted file mode 100644 index afaa7fcabdff..000000000000 --- a/core/ajax/update.php +++ /dev/null @@ -1,215 +0,0 @@ - - * @author Joas Schilling - * @author Lukas Reschke - * @author Michael Gapczynski - * @author Morris Jobke - * @author Robin Appelman - * @author Thomas Müller - * @author Victor Dubiniuk - * @author Vincent Petry - * - * @copyright Copyright (c) 2018, ownCloud GmbH - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see - * - */ -use Symfony\Component\EventDispatcher\GenericEvent; - -set_time_limit(0); -require_once '../../lib/base.php'; - -$l = \OC::$server->getL10N('core'); - -$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')); - -class FeedBackHandler { - /** @var integer */ - private $progressStateMax = 100; - /** @var integer */ - private $progressStateStep = 0; - /** @var string */ - private $currentStep; - - public function __construct(\OCP\IEventSource $eventSource, \OCP\IL10N $l10n) { - $this->eventSource = $eventSource; - $this->l10n = $l10n; - } - - public function handleRepairFeedback($event) { - if (!$event instanceof GenericEvent) { - return; - } - - switch ($event->getSubject()) { - case '\OC\Repair::startProgress': - $this->progressStateMax = $event->getArgument(0); - $this->progressStateStep = 0; - $this->currentStep = $event->getArgument(1); - break; - case '\OC\Repair::advance': - $this->progressStateStep += $event->getArgument(0); - $desc = $event->getArgument(1); - if (empty($desc)) { - $desc = $this->currentStep; - } - $this->eventSource->send('success', (string)$this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $desc])); - break; - case '\OC\Repair::finishProgress': - $this->progressStateMax = $this->progressStateStep; - $this->eventSource->send('success', (string)$this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $this->currentStep])); - break; - case '\OC\Repair::step': - break; - case '\OC\Repair::info': - break; - case '\OC\Repair::warning': - $this->eventSource->send('notice', (string)$this->l10n->t('Repair warning: ') . $event->getArgument(0)); - break; - case '\OC\Repair::error': - $this->eventSource->send('notice', (string)$this->l10n->t('Repair error: ') . $event->getArgument(0)); - break; - } - } -} - -if (OC::checkUpgrade(false)) { - - $config = \OC::$server->getSystemConfig(); - if ($config->getValue('upgrade.disable-web', false)) { - $eventSource->send('failure', (string)$l->t('Please use the command line updater because automatic updating is disabled in the config.php.')); - $eventSource->close(); - exit(); - } - - // if a user is currently logged in, their session must be ignored to - // avoid side effects - \OC_User::setIncognitoMode(true); - - $logger = \OC::$server->getLogger(); - $config = \OC::$server->getConfig(); - $updater = new \OC\Updater( - $config, - \OC::$server->getIntegrityCodeChecker(), - $logger - ); - $incompatibleApps = []; - $disabledThirdPartyApps = []; - - $dispatcher = \OC::$server->getEventDispatcher(); - $dispatcher->addListener('\OC\DB\Migrator::executeSql', function($event) use ($eventSource, $l) { - if ($event instanceof GenericEvent) { - $eventSource->send('success', (string)$l->t('[%d / %d]: %s', [$event[0], $event[1], $event->getSubject()])); - } - }); - $dispatcher->addListener('\OC\DB\Migrator::checkTable', function($event) use ($eventSource, $l) { - if ($event instanceof GenericEvent) { - $eventSource->send('success', (string)$l->t('[%d / %d]: Checking table %s', [$event[0], $event[1], $event->getSubject()])); - } - }); - $feedBack = new FeedBackHandler($eventSource, $l); - $dispatcher->addListener('\OC\Repair::startProgress', [$feedBack, 'handleRepairFeedback']); - $dispatcher->addListener('\OC\Repair::advance', [$feedBack, 'handleRepairFeedback']); - $dispatcher->addListener('\OC\Repair::finishProgress', [$feedBack, 'handleRepairFeedback']); - $dispatcher->addListener('\OC\Repair::step', [$feedBack, 'handleRepairFeedback']); - $dispatcher->addListener('\OC\Repair::info', [$feedBack, 'handleRepairFeedback']); - $dispatcher->addListener('\OC\Repair::warning', [$feedBack, 'handleRepairFeedback']); - $dispatcher->addListener('\OC\Repair::error', [$feedBack, 'handleRepairFeedback']); - - $updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($eventSource, $l) { - $eventSource->send('success', (string)$l->t('Turned on maintenance mode')); - }); - $updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($eventSource, $l) { - $eventSource->send('success', (string)$l->t('Turned off maintenance mode')); - }); - $updater->listen('\OC\Updater', 'maintenanceActive', function () use ($eventSource, $l) { - $eventSource->send('success', (string)$l->t('Maintenance mode is kept active')); - }); - $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use($eventSource, $l) { - $eventSource->send('success', (string)$l->t('Updating database schema')); - }); - $updater->listen('\OC\Updater', 'dbUpgrade', function () use ($eventSource, $l) { - $eventSource->send('success', (string)$l->t('Updated database')); - }); - $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($eventSource, $l) { - $eventSource->send('success', (string)$l->t('Checking whether the database schema can be updated (this can take a long time depending on the database size)')); - }); - $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($eventSource, $l) { - $eventSource->send('success', (string)$l->t('Checked database schema update')); - }); - $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($eventSource, $l) { - $eventSource->send('success', (string)$l->t('Checking updates of apps')); - }); - $updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($eventSource, $l) { - $eventSource->send('success', (string)$l->t('Checking whether the database schema for %s can be updated (this can take a long time depending on the database size)', [$app])); - }); - $updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($eventSource, $l) { - $eventSource->send('success', (string)$l->t('Checked database schema update for apps')); - }); - $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($eventSource, $l) { - $eventSource->send('success', (string)$l->t('Updated "%s" to %s', [$app, $version])); - }); - $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use (&$incompatibleApps) { - $incompatibleApps[]= $app; - }); - $updater->listen('\OC\Updater', 'failure', function ($message) use ($eventSource, $config) { - $eventSource->send('failure', $message); - $eventSource->close(); - $config->setSystemValue('maintenance', false); - }); - $updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use($eventSource, $l) { - $eventSource->send('success', (string)$l->t('Set log level to debug')); - }); - $updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($eventSource, $l) { - $eventSource->send('success', (string)$l->t('Reset log level')); - }); - $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use($eventSource, $l) { - $eventSource->send('success', (string)$l->t('Starting code integrity check')); - }); - $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use($eventSource, $l) { - $eventSource->send('success', (string)$l->t('Finished code integrity check')); - }); - - try { - $updater->upgrade(); - } catch (\Exception $e) { - $eventSource->send('failure', get_class($e) . ': ' . $e->getMessage()); - $eventSource->close(); - exit(); - } - - $disabledApps = []; - foreach ($disabledThirdPartyApps as $app) { - $disabledApps[$app] = (string) $l->t('%s (3rdparty)', [$app]); - } - foreach ($incompatibleApps as $app) { - $disabledApps[$app] = (string) $l->t('%s (incompatible)', [$app]); - } - - if (!empty($disabledApps)) { - $eventSource->send('notice', - (string)$l->t('Following apps have been disabled: %s', implode(', ', $disabledApps))); - } -} else { - $eventSource->send('notice', (string)$l->t('Already up to date')); -} - -$eventSource->send('done', ''); -$eventSource->close(); - diff --git a/core/css/update.css b/core/css/update.css deleted file mode 100644 index b1e086af3fd2..000000000000 --- a/core/css/update.css +++ /dev/null @@ -1,26 +0,0 @@ -#update-progress-icon { - height: 32px; - margin: 10px; - background-size: 32px; -} - -#update-progress-message { - margin-bottom: 10px; -} - -.update-show-detailed { - padding: 13px; - display: block; -} - -#body-login .update a.update-show-detailed { - border-bottom: inherit; -} - -#update-progress-detailed { - text-align: left; -} - -#body-login .warning.hidden { - display: none; -} \ No newline at end of file diff --git a/core/js/update.js b/core/js/update.js deleted file mode 100644 index f1f7a9ca2d8b..000000000000 --- a/core/js/update.js +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2014 - * - * This file is licensed under the Affero General Public License version 3 - * or later. - * - * See the COPYING-README file. - * - */ - -(function() { - OC.Update = { - _started : false, - - /** - * Start the upgrade process. - * - * @param $el progress list element - */ - start: function($el, options) { - if (this._started) { - return; - } - - var hasWarnings = false; - - this.$el = $el; - - this._started = true; - - var self = this; - - $(window).on('beforeunload.inprogress', function () { - return t('core', 'The upgrade is in progress, leaving this page might interrupt the process in some environments.'); - }); - - $('#update-progress-title').html(t( - 'core', - 'Updating to {version}', { - version: options.version - }) - ); - - var updateEventSource = new OC.EventSource(OC.webroot+'/core/ajax/update.php'); - updateEventSource.listen('success', function(message) { - self.setMessage(message); - }); - updateEventSource.listen('notice', function(message) { - self.setPermanentMessage(message); - hasWarnings = true; - }); - updateEventSource.listen('error', function(message) { - $('#update-progress-message').hide(); - $('#update-progress-icon') - .addClass('icon-error-white') - .removeClass('icon-loading-dark'); - message = message || t('core', 'An error occurred.'); - $(window).off('beforeunload.inprogress'); - self.setErrorMessage(message); - message = t('core', 'Please reload the page.'); - $('').addClass('error').append(''+message+'
').appendTo($el); - updateEventSource.close(); - }); - updateEventSource.listen('failure', function(message) { - $(window).off('beforeunload.inprogress'); - $('#update-progress-message').hide(); - $('#update-progress-icon') - .addClass('icon-error-white') - .removeClass('icon-loading-dark'); - - self.setErrorMessage(message); - var span = $('') - .addClass('bold'); - if(message === 'Exception: Updates between multiple major versions and downgrades are unsupported.') { - span.append(t('core', 'The update was unsuccessful. For more information check our forum post covering this issue.', {'url': 'https://central.owncloud.org/t/updates-between-multiple-major-versions-are-unsupported/815'})); - } else { - span.append(t('core', 'The update was unsuccessful. ' + - 'Please report this issue to the ' + - 'ownCloud community.')); - } - span.appendTo($el); - }); - updateEventSource.listen('done', function() { - $(window).off('beforeunload.inprogress'); - - $('#update-progress-message').hide(); - - $('#update-progress-icon') - .addClass('icon-checkmark-white') - .removeClass('icon-loading-dark'); - - if (hasWarnings) { - $el.find('.update-show-detailed').before( - $('') - .append('
') - .append(t('core', 'The update was successful. There were warnings.')) - ); - var message = t('core', 'Please reload the page.'); - $('').append(message).append('
').appendTo($el); - } else { - // FIXME: use product name - $('') - .append(t('core', 'The update was successful. Redirecting you to ownCloud now.')) - .appendTo($el); - setTimeout(function () { - OC.redirect(OC.webroot + '/'); - }, 3000); - } - }); - }, - - setMessage: function(message) { - $('#update-progress-message').html(message); - $('#update-progress-detailed') - .append($('')) - .append(message) - .append($('
')); - }, - - setPermanentMessage: function(message) { - $('#update-progress-message').html(message); - $('#update-progress-message-warnings') - .show() - .append($('
    ').append(message)); - $('#update-progress-detailed') - .append($('')) - .append(message) - .append($('
    ')); - }, - - setErrorMessage: function (message) { - $('#update-progress-message-error') - .show() - .html(message); - $('#update-progress-detailed') - .append($('')) - .append(message) - .append($('
    ')); - } - }; - -})(); - -$(document).ready(function() { - $('.updateButton').on('click', function() { - var $updateEl = $('.update'); - var $progressEl = $('.update-progress'); - $progressEl.removeClass('hidden'); - $('.updateOverview').addClass('hidden'); - $('#update-progress-message-error').hide(); - $('#update-progress-message-warnings').hide(); - OC.Update.start($progressEl, { - productName: $updateEl.attr('data-productname'), - version: $updateEl.attr('data-version') - }); - return false; - }); - $('.update-show-detailed').on('click', function() { - $('#update-progress-detailed').toggleClass('hidden'); - return false; - }); -}); diff --git a/core/routes.php b/core/routes.php index 082e2647366e..628e0e645590 100644 --- a/core/routes.php +++ b/core/routes.php @@ -74,9 +74,6 @@ // oC JS config $this->create('js_config', '/core/js/oc.js') ->actionInclude('core/js/config.php'); -// Routing -$this->create('core_ajax_update', '/core/ajax/update.php') - ->actionInclude('core/ajax/update.php'); // File routes $this->create('files.viewcontroller.showFile', '/f/{fileId}')->action(function($urlParams) { diff --git a/core/templates/update.admin.php b/core/templates/update.admin.php deleted file mode 100644 index 895891e14b2a..000000000000 --- a/core/templates/update.admin.php +++ /dev/null @@ -1,43 +0,0 @@ -
    -
    - -

    t('App update required')); ?>

    - -

    t('%s will be updated to version %s', - [$_['productName'], $_['version']])); ?>

    - - -
    - t('These apps will be updated:')); ?> -
      - -
    • ()
    • - -
    -
    - - -
    - t('The theme %s has been disabled.', [$_['oldTheme']])) ?> -
    - -
    - t('Please make sure that the database, the config folder and the data folder have been backed up before proceeding.')) ?> -
    - -
    - t('To avoid timeouts with larger installations, you can instead run the following command from your installation directory:')) ?> -
    ./occ upgrade
    -
    -
    - - -
    diff --git a/core/templates/update.use-cli.php b/core/templates/update.use-cli.php index 9a1fd6da9e60..ad75cd5b9ae7 100644 --- a/core/templates/update.use-cli.php +++ b/core/templates/update.use-cli.php @@ -2,11 +2,9 @@

    t('Update needed')) ?>

    - t('It looks like your instance may host many files and/or users. To ensure a smooth upgrade process, please use the command line updater (occ upgrade).')); - } else { - p($l->t('Automatic updating is disabled in config.php. To upgrade your instance, please use the command line updater (occ upgrade).')); - } ?>

    + t('To upgrade your instance, please use the command line updater (occ upgrade).')); + ?>

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

    diff --git a/lib/base.php b/lib/base.php index 860fd0728e26..11cc37a2604e 100644 --- a/lib/base.php +++ b/lib/base.php @@ -346,59 +346,17 @@ public static function checkUpgrade($showTemplate = true) { private static function printUpgradePage() { $systemConfig = \OC::$server->getSystemConfig(); - $disableWebUpdater = $systemConfig->getValue('upgrade.disable-web', false); - $tooBig = false; - if (!$disableWebUpdater) { - $apps = \OC::$server->getAppManager(); - $tooBig = $apps->isInstalled('user_ldap') || $apps->isInstalled('user_shibboleth'); - if (!$tooBig) { - // count users - $db = new \OC\User\Database(); - $tooBig = ($db->countUsers() > 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'); - - /** @var \OC\App\AppManager $appManager */ - $appManager = \OC::$server->getAppManager(); + // send http status 503 + header('HTTP/1.1 503 Service Temporarily Unavailable'); + header('Status: 503 Service Temporarily Unavailable'); + header('Retry-After: 120'); - $tmpl = new OC_Template('', 'update.admin', 'guest'); - $tmpl->assign('version', OC_Util::getVersionString()); - $tmpl->assign('isAppsOnlyUpgrade', $isAppsOnlyUpgrade); + // render error page + $template = new OC_Template('', 'update.use-cli', 'guest'); + $template->assign('productName', 'ownCloud'); // for now + $template->assign('version', OC_Util::getVersionString()); - // get third party apps - $ocVersion = \OCP\Util::getVersion(); - $tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion)); - $tmpl->assign('productName', 'ownCloud'); // for now - $tmpl->assign('oldTheme', $oldTheme); - $tmpl->printPage(); + $template->printPage(); } public static function initSession() {