From 43c191fffb6f423909488bab41d90ca3af0d6edb Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Mon, 22 Sep 2014 11:59:13 +0200 Subject: show upgrade errors as error in the console and report back that the upgrade process failed if it did --- core/command/upgrade.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'core') diff --git a/core/command/upgrade.php b/core/command/upgrade.php index d037082c5e8..722ba4f9db9 100644 --- a/core/command/upgrade.php +++ b/core/command/upgrade.php @@ -22,6 +22,8 @@ class Upgrade extends Command { const ERROR_UP_TO_DATE = 3; const ERROR_INVALID_ARGUMENTS = 4; + public $upgradeFailed = false; + protected function configure() { $this ->setName('upgrade') @@ -75,6 +77,7 @@ class Upgrade extends Command { } if(\OC::checkUpgrade(false)) { + $self = $this; $updater = new Updater(); $updater->setSimulateStepEnabled($simulateStepEnabled); @@ -83,15 +86,14 @@ class Upgrade extends Command { $updater->listen('\OC\Updater', 'maintenanceStart', function () use($output) { $output->writeln('Turned on maintenance mode'); }); - $updater->listen('\OC\Updater', 'maintenanceEnd', function () use($output, $updateStepEnabled) { - $output->writeln('Turned off maintenance mode'); - if (!$updateStepEnabled) { - $output->writeln('Update simulation successful'); - } - else { - $output->writeln('Update successful'); - } - }); + $updater->listen('\OC\Updater', 'maintenanceEnd', + function () use($output, $updateStepEnabled, $self) { + $output->writeln('Turned off maintenance mode'); + $mode = $updateStepEnabled ? 'Update' : 'Update simulation'; + $status = $self->upgradeFailed ? 'failed' : 'successful'; + $message = "$mode $status"; + $output->writeln($message); + }); $updater->listen('\OC\Updater', 'dbUpgrade', function () use($output) { $output->writeln('Updated database'); }); @@ -102,9 +104,9 @@ class Upgrade extends Command { $output->writeln('Disabled incompatible apps: ' . implode(', ', $appList) . ''); }); - $updater->listen('\OC\Updater', 'failure', function ($message) use($output) { - $output->writeln($message); - \OC_Config::setValue('maintenance', false); + $updater->listen('\OC\Updater', 'failure', function ($message) use($output, $self) { + $output->writeln("$message"); + $self->upgradeFailed = true; }); $updater->upgrade(); -- cgit v1.2.3 From e655d32979c56c8ae231d44b8c3e864a33f16bf4 Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Mon, 22 Sep 2014 12:00:22 +0200 Subject: remove bootstrapping - occ can by definition only be executed if ownCloud is installed - base.php is required earlier already --- core/command/upgrade.php | 8 -------- 1 file changed, 8 deletions(-) (limited to 'core') diff --git a/core/command/upgrade.php b/core/command/upgrade.php index 722ba4f9db9..c626f24bcc3 100644 --- a/core/command/upgrade.php +++ b/core/command/upgrade.php @@ -50,14 +50,6 @@ class Upgrade extends Command { */ protected function execute(InputInterface $input, OutputInterface $output) { - require_once \OC::$SERVERROOT . '/lib/base.php'; - - // Don't do anything if ownCloud has not been installed - if(!\OC_Config::getValue('installed', false)) { - $output->writeln('ownCloud has not yet been installed'); - return self::ERROR_NOT_INSTALLED; - } - $simulateStepEnabled = true; $updateStepEnabled = true; -- cgit v1.2.3 From a348a6f4507e28e6c5093669e17e10c42941007f Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Mon, 22 Sep 2014 12:04:48 +0200 Subject: no loner use deprecated class \OC_Config --- core/command/upgrade.php | 17 +++++++++++++++-- core/register_command.php | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'core') diff --git a/core/command/upgrade.php b/core/command/upgrade.php index c626f24bcc3..5b9432d631b 100644 --- a/core/command/upgrade.php +++ b/core/command/upgrade.php @@ -9,6 +9,7 @@ namespace OC\Core\Command; use OC\Updater; +use OCP\IConfig; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -24,6 +25,18 @@ class Upgrade extends Command { public $upgradeFailed = false; + /** + * @var IConfig + */ + private $config; + + /** + * @param IConfig $config + */ + public function __construct(IConfig $config) { + $this->config = $config; + } + protected function configure() { $this ->setName('upgrade') @@ -106,7 +119,7 @@ class Upgrade extends Command { $this->postUpgradeCheck($input, $output); return self::ERROR_SUCCESS; - } else if(\OC_Config::getValue('maintenance', false)) { + } else if($this->config->getSystemValue('maintenance', false)) { //Possible scenario: ownCloud core is updated but an app failed $output->writeln('ownCloud is in maintenance mode'); $output->write('Maybe an upgrade is already in process. Please check the ' @@ -128,7 +141,7 @@ class Upgrade extends Command { * @param OutputInterface $output output interface */ protected function postUpgradeCheck(InputInterface $input, OutputInterface $output) { - $trustedDomains = \OC_Config::getValue('trusted_domains', array()); + $trustedDomains = $this->config->getSystemValue('trusted_domains', array()); if (empty($trustedDomains)) { $output->write( 'The setting "trusted_domains" could not be ' . diff --git a/core/register_command.php b/core/register_command.php index b02988bbdd8..aaf10d946b2 100644 --- a/core/register_command.php +++ b/core/register_command.php @@ -12,7 +12,7 @@ $repair = new \OC\Repair(\OC\Repair::getRepairSteps()); $application->add(new OC\Core\Command\Status); $application->add(new OC\Core\Command\Db\GenerateChangeScript()); $application->add(new OC\Core\Command\Db\ConvertType(OC_Config::getObject(), new \OC\DB\ConnectionFactory())); -$application->add(new OC\Core\Command\Upgrade()); +$application->add(new OC\Core\Command\Upgrade(\OC::$server->getConfig())); $application->add(new OC\Core\Command\Maintenance\SingleUser()); $application->add(new OC\Core\Command\Maintenance\Mode(OC_Config::getObject())); $application->add(new OC\Core\Command\App\Disable()); -- cgit v1.2.3