@@ -46,250 +46,250 @@ |
||
| 46 | 46 | use Symfony\Component\EventDispatcher\GenericEvent; |
| 47 | 47 | |
| 48 | 48 | class Upgrade extends Command { |
| 49 | - public const ERROR_SUCCESS = 0; |
|
| 50 | - public const ERROR_NOT_INSTALLED = 1; |
|
| 51 | - public const ERROR_MAINTENANCE_MODE = 2; |
|
| 52 | - public const ERROR_UP_TO_DATE = 0; |
|
| 53 | - public const ERROR_INVALID_ARGUMENTS = 4; |
|
| 54 | - public const ERROR_FAILURE = 5; |
|
| 49 | + public const ERROR_SUCCESS = 0; |
|
| 50 | + public const ERROR_NOT_INSTALLED = 1; |
|
| 51 | + public const ERROR_MAINTENANCE_MODE = 2; |
|
| 52 | + public const ERROR_UP_TO_DATE = 0; |
|
| 53 | + public const ERROR_INVALID_ARGUMENTS = 4; |
|
| 54 | + public const ERROR_FAILURE = 5; |
|
| 55 | 55 | |
| 56 | - /** @var IConfig */ |
|
| 57 | - private $config; |
|
| 56 | + /** @var IConfig */ |
|
| 57 | + private $config; |
|
| 58 | 58 | |
| 59 | - /** @var ILogger */ |
|
| 60 | - private $logger; |
|
| 59 | + /** @var ILogger */ |
|
| 60 | + private $logger; |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * @param IConfig $config |
|
| 64 | - * @param ILogger $logger |
|
| 65 | - * @param Installer $installer |
|
| 66 | - */ |
|
| 67 | - public function __construct(IConfig $config, ILogger $logger, Installer $installer) { |
|
| 68 | - parent::__construct(); |
|
| 69 | - $this->config = $config; |
|
| 70 | - $this->logger = $logger; |
|
| 71 | - $this->installer = $installer; |
|
| 72 | - } |
|
| 62 | + /** |
|
| 63 | + * @param IConfig $config |
|
| 64 | + * @param ILogger $logger |
|
| 65 | + * @param Installer $installer |
|
| 66 | + */ |
|
| 67 | + public function __construct(IConfig $config, ILogger $logger, Installer $installer) { |
|
| 68 | + parent::__construct(); |
|
| 69 | + $this->config = $config; |
|
| 70 | + $this->logger = $logger; |
|
| 71 | + $this->installer = $installer; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - protected function configure() { |
|
| 75 | - $this |
|
| 76 | - ->setName('upgrade') |
|
| 77 | - ->setDescription('run upgrade routines after installation of a new release. The release has to be installed before.'); |
|
| 78 | - } |
|
| 74 | + protected function configure() { |
|
| 75 | + $this |
|
| 76 | + ->setName('upgrade') |
|
| 77 | + ->setDescription('run upgrade routines after installation of a new release. The release has to be installed before.'); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * Execute the upgrade command |
|
| 82 | - * |
|
| 83 | - * @param InputInterface $input input interface |
|
| 84 | - * @param OutputInterface $output output interface |
|
| 85 | - */ |
|
| 86 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 87 | - if (Util::needUpgrade()) { |
|
| 88 | - if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
| 89 | - // Prepend each line with a little timestamp |
|
| 90 | - $timestampFormatter = new TimestampFormatter($this->config, $output->getFormatter()); |
|
| 91 | - $output->setFormatter($timestampFormatter); |
|
| 92 | - } |
|
| 80 | + /** |
|
| 81 | + * Execute the upgrade command |
|
| 82 | + * |
|
| 83 | + * @param InputInterface $input input interface |
|
| 84 | + * @param OutputInterface $output output interface |
|
| 85 | + */ |
|
| 86 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 87 | + if (Util::needUpgrade()) { |
|
| 88 | + if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
| 89 | + // Prepend each line with a little timestamp |
|
| 90 | + $timestampFormatter = new TimestampFormatter($this->config, $output->getFormatter()); |
|
| 91 | + $output->setFormatter($timestampFormatter); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - $self = $this; |
|
| 95 | - $updater = new Updater( |
|
| 96 | - $this->config, |
|
| 97 | - \OC::$server->getIntegrityCodeChecker(), |
|
| 98 | - $this->logger, |
|
| 99 | - $this->installer |
|
| 100 | - ); |
|
| 94 | + $self = $this; |
|
| 95 | + $updater = new Updater( |
|
| 96 | + $this->config, |
|
| 97 | + \OC::$server->getIntegrityCodeChecker(), |
|
| 98 | + $this->logger, |
|
| 99 | + $this->installer |
|
| 100 | + ); |
|
| 101 | 101 | |
| 102 | - $dispatcher = \OC::$server->getEventDispatcher(); |
|
| 103 | - $progress = new ProgressBar($output); |
|
| 104 | - $progress->setFormat(" %message%\n %current%/%max% [%bar%] %percent:3s%%"); |
|
| 105 | - $listener = function ($event) use ($progress, $output) { |
|
| 106 | - if ($event instanceof GenericEvent) { |
|
| 107 | - $message = $event->getSubject(); |
|
| 108 | - if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
| 109 | - $output->writeln(' Checking table ' . $message); |
|
| 110 | - } else { |
|
| 111 | - if (strlen($message) > 60) { |
|
| 112 | - $message = substr($message, 0, 57) . '...'; |
|
| 113 | - } |
|
| 114 | - $progress->setMessage($message); |
|
| 115 | - if ($event[0] === 1) { |
|
| 116 | - $output->writeln(''); |
|
| 117 | - $progress->start($event[1]); |
|
| 118 | - } |
|
| 119 | - $progress->setProgress($event[0]); |
|
| 120 | - if ($event[0] === $event[1]) { |
|
| 121 | - $progress->setMessage('Done'); |
|
| 122 | - $progress->finish(); |
|
| 123 | - $output->writeln(''); |
|
| 124 | - } |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - }; |
|
| 128 | - $repairListener = function ($event) use ($progress, $output) { |
|
| 129 | - if (!$event instanceof GenericEvent) { |
|
| 130 | - return; |
|
| 131 | - } |
|
| 132 | - switch ($event->getSubject()) { |
|
| 133 | - case '\OC\Repair::startProgress': |
|
| 134 | - $progress->setMessage('Starting ...'); |
|
| 135 | - $output->writeln($event->getArgument(1)); |
|
| 136 | - $output->writeln(''); |
|
| 137 | - $progress->start($event->getArgument(0)); |
|
| 138 | - break; |
|
| 139 | - case '\OC\Repair::advance': |
|
| 140 | - $desc = $event->getArgument(1); |
|
| 141 | - if (!empty($desc)) { |
|
| 142 | - $progress->setMessage($desc); |
|
| 143 | - } |
|
| 144 | - $progress->advance($event->getArgument(0)); |
|
| 102 | + $dispatcher = \OC::$server->getEventDispatcher(); |
|
| 103 | + $progress = new ProgressBar($output); |
|
| 104 | + $progress->setFormat(" %message%\n %current%/%max% [%bar%] %percent:3s%%"); |
|
| 105 | + $listener = function ($event) use ($progress, $output) { |
|
| 106 | + if ($event instanceof GenericEvent) { |
|
| 107 | + $message = $event->getSubject(); |
|
| 108 | + if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
| 109 | + $output->writeln(' Checking table ' . $message); |
|
| 110 | + } else { |
|
| 111 | + if (strlen($message) > 60) { |
|
| 112 | + $message = substr($message, 0, 57) . '...'; |
|
| 113 | + } |
|
| 114 | + $progress->setMessage($message); |
|
| 115 | + if ($event[0] === 1) { |
|
| 116 | + $output->writeln(''); |
|
| 117 | + $progress->start($event[1]); |
|
| 118 | + } |
|
| 119 | + $progress->setProgress($event[0]); |
|
| 120 | + if ($event[0] === $event[1]) { |
|
| 121 | + $progress->setMessage('Done'); |
|
| 122 | + $progress->finish(); |
|
| 123 | + $output->writeln(''); |
|
| 124 | + } |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + }; |
|
| 128 | + $repairListener = function ($event) use ($progress, $output) { |
|
| 129 | + if (!$event instanceof GenericEvent) { |
|
| 130 | + return; |
|
| 131 | + } |
|
| 132 | + switch ($event->getSubject()) { |
|
| 133 | + case '\OC\Repair::startProgress': |
|
| 134 | + $progress->setMessage('Starting ...'); |
|
| 135 | + $output->writeln($event->getArgument(1)); |
|
| 136 | + $output->writeln(''); |
|
| 137 | + $progress->start($event->getArgument(0)); |
|
| 138 | + break; |
|
| 139 | + case '\OC\Repair::advance': |
|
| 140 | + $desc = $event->getArgument(1); |
|
| 141 | + if (!empty($desc)) { |
|
| 142 | + $progress->setMessage($desc); |
|
| 143 | + } |
|
| 144 | + $progress->advance($event->getArgument(0)); |
|
| 145 | 145 | |
| 146 | - break; |
|
| 147 | - case '\OC\Repair::finishProgress': |
|
| 148 | - $progress->setMessage('Done'); |
|
| 149 | - $progress->finish(); |
|
| 150 | - $output->writeln(''); |
|
| 151 | - break; |
|
| 152 | - case '\OC\Repair::step': |
|
| 153 | - if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
| 154 | - $output->writeln('<info>Repair step: ' . $event->getArgument(0) . '</info>'); |
|
| 155 | - } |
|
| 156 | - break; |
|
| 157 | - case '\OC\Repair::info': |
|
| 158 | - if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
| 159 | - $output->writeln('<info>Repair info: ' . $event->getArgument(0) . '</info>'); |
|
| 160 | - } |
|
| 161 | - break; |
|
| 162 | - case '\OC\Repair::warning': |
|
| 163 | - $output->writeln('<error>Repair warning: ' . $event->getArgument(0) . '</error>'); |
|
| 164 | - break; |
|
| 165 | - case '\OC\Repair::error': |
|
| 166 | - $output->writeln('<error>Repair error: ' . $event->getArgument(0) . '</error>'); |
|
| 167 | - break; |
|
| 168 | - } |
|
| 169 | - }; |
|
| 146 | + break; |
|
| 147 | + case '\OC\Repair::finishProgress': |
|
| 148 | + $progress->setMessage('Done'); |
|
| 149 | + $progress->finish(); |
|
| 150 | + $output->writeln(''); |
|
| 151 | + break; |
|
| 152 | + case '\OC\Repair::step': |
|
| 153 | + if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
| 154 | + $output->writeln('<info>Repair step: ' . $event->getArgument(0) . '</info>'); |
|
| 155 | + } |
|
| 156 | + break; |
|
| 157 | + case '\OC\Repair::info': |
|
| 158 | + if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
| 159 | + $output->writeln('<info>Repair info: ' . $event->getArgument(0) . '</info>'); |
|
| 160 | + } |
|
| 161 | + break; |
|
| 162 | + case '\OC\Repair::warning': |
|
| 163 | + $output->writeln('<error>Repair warning: ' . $event->getArgument(0) . '</error>'); |
|
| 164 | + break; |
|
| 165 | + case '\OC\Repair::error': |
|
| 166 | + $output->writeln('<error>Repair error: ' . $event->getArgument(0) . '</error>'); |
|
| 167 | + break; |
|
| 168 | + } |
|
| 169 | + }; |
|
| 170 | 170 | |
| 171 | - $dispatcher->addListener('\OC\DB\Migrator::executeSql', $listener); |
|
| 172 | - $dispatcher->addListener('\OC\DB\Migrator::checkTable', $listener); |
|
| 173 | - $dispatcher->addListener('\OC\Repair::startProgress', $repairListener); |
|
| 174 | - $dispatcher->addListener('\OC\Repair::advance', $repairListener); |
|
| 175 | - $dispatcher->addListener('\OC\Repair::finishProgress', $repairListener); |
|
| 176 | - $dispatcher->addListener('\OC\Repair::step', $repairListener); |
|
| 177 | - $dispatcher->addListener('\OC\Repair::info', $repairListener); |
|
| 178 | - $dispatcher->addListener('\OC\Repair::warning', $repairListener); |
|
| 179 | - $dispatcher->addListener('\OC\Repair::error', $repairListener); |
|
| 171 | + $dispatcher->addListener('\OC\DB\Migrator::executeSql', $listener); |
|
| 172 | + $dispatcher->addListener('\OC\DB\Migrator::checkTable', $listener); |
|
| 173 | + $dispatcher->addListener('\OC\Repair::startProgress', $repairListener); |
|
| 174 | + $dispatcher->addListener('\OC\Repair::advance', $repairListener); |
|
| 175 | + $dispatcher->addListener('\OC\Repair::finishProgress', $repairListener); |
|
| 176 | + $dispatcher->addListener('\OC\Repair::step', $repairListener); |
|
| 177 | + $dispatcher->addListener('\OC\Repair::info', $repairListener); |
|
| 178 | + $dispatcher->addListener('\OC\Repair::warning', $repairListener); |
|
| 179 | + $dispatcher->addListener('\OC\Repair::error', $repairListener); |
|
| 180 | 180 | |
| 181 | 181 | |
| 182 | - $updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($output) { |
|
| 183 | - $output->writeln('<info>Turned on maintenance mode</info>'); |
|
| 184 | - }); |
|
| 185 | - $updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($output) { |
|
| 186 | - $output->writeln('<info>Turned off maintenance mode</info>'); |
|
| 187 | - }); |
|
| 188 | - $updater->listen('\OC\Updater', 'maintenanceActive', function () use ($output) { |
|
| 189 | - $output->writeln('<info>Maintenance mode is kept active</info>'); |
|
| 190 | - }); |
|
| 191 | - $updater->listen('\OC\Updater', 'updateEnd', |
|
| 192 | - function ($success) use ($output, $self) { |
|
| 193 | - if ($success) { |
|
| 194 | - $message = "<info>Update successful</info>"; |
|
| 195 | - } else { |
|
| 196 | - $message = "<error>Update failed</error>"; |
|
| 197 | - } |
|
| 198 | - $output->writeln($message); |
|
| 199 | - }); |
|
| 200 | - $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use ($output) { |
|
| 201 | - $output->writeln('<info>Updating database schema</info>'); |
|
| 202 | - }); |
|
| 203 | - $updater->listen('\OC\Updater', 'dbUpgrade', function () use ($output) { |
|
| 204 | - $output->writeln('<info>Updated database</info>'); |
|
| 205 | - }); |
|
| 206 | - $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use ($output) { |
|
| 207 | - $output->writeln('<info>Checking whether the database schema can be updated (this can take a long time depending on the database size)</info>'); |
|
| 208 | - }); |
|
| 209 | - $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($output) { |
|
| 210 | - $output->writeln('<info>Checked database schema update</info>'); |
|
| 211 | - }); |
|
| 212 | - $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use ($output) { |
|
| 213 | - $output->writeln('<comment>Disabled incompatible app: ' . $app . '</comment>'); |
|
| 214 | - }); |
|
| 215 | - $updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($output) { |
|
| 216 | - $output->writeln('<info>Checking for update of app ' . $app . ' in appstore</info>'); |
|
| 217 | - }); |
|
| 218 | - $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($output) { |
|
| 219 | - $output->writeln('<info>Update app ' . $app . ' from appstore</info>'); |
|
| 220 | - }); |
|
| 221 | - $updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($output) { |
|
| 222 | - $output->writeln('<info>Checked for update of app "' . $app . '" in appstore </info>'); |
|
| 223 | - }); |
|
| 224 | - $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($output) { |
|
| 225 | - $output->writeln('<info>Checking updates of apps</info>'); |
|
| 226 | - }); |
|
| 227 | - $updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($output) { |
|
| 228 | - $output->writeln("<info>Checking whether the database schema for <$app> can be updated (this can take a long time depending on the database size)</info>"); |
|
| 229 | - }); |
|
| 230 | - $updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($output) { |
|
| 231 | - $output->writeln('<info>Checked database schema update for apps</info>'); |
|
| 232 | - }); |
|
| 233 | - $updater->listen('\OC\Updater', 'appUpgradeStarted', function ($app, $version) use ($output) { |
|
| 234 | - $output->writeln("<info>Updating <$app> ...</info>"); |
|
| 235 | - }); |
|
| 236 | - $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($output) { |
|
| 237 | - $output->writeln("<info>Updated <$app> to $version</info>"); |
|
| 238 | - }); |
|
| 239 | - $updater->listen('\OC\Updater', 'failure', function ($message) use ($output, $self) { |
|
| 240 | - $output->writeln("<error>$message</error>"); |
|
| 241 | - }); |
|
| 242 | - $updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use ($output) { |
|
| 243 | - $output->writeln("<info>Setting log level to debug</info>"); |
|
| 244 | - }); |
|
| 245 | - $updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use ($output) { |
|
| 246 | - $output->writeln("<info>Resetting log level</info>"); |
|
| 247 | - }); |
|
| 248 | - $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use ($output) { |
|
| 249 | - $output->writeln("<info>Starting code integrity check...</info>"); |
|
| 250 | - }); |
|
| 251 | - $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use ($output) { |
|
| 252 | - $output->writeln("<info>Finished code integrity check</info>"); |
|
| 253 | - }); |
|
| 182 | + $updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($output) { |
|
| 183 | + $output->writeln('<info>Turned on maintenance mode</info>'); |
|
| 184 | + }); |
|
| 185 | + $updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($output) { |
|
| 186 | + $output->writeln('<info>Turned off maintenance mode</info>'); |
|
| 187 | + }); |
|
| 188 | + $updater->listen('\OC\Updater', 'maintenanceActive', function () use ($output) { |
|
| 189 | + $output->writeln('<info>Maintenance mode is kept active</info>'); |
|
| 190 | + }); |
|
| 191 | + $updater->listen('\OC\Updater', 'updateEnd', |
|
| 192 | + function ($success) use ($output, $self) { |
|
| 193 | + if ($success) { |
|
| 194 | + $message = "<info>Update successful</info>"; |
|
| 195 | + } else { |
|
| 196 | + $message = "<error>Update failed</error>"; |
|
| 197 | + } |
|
| 198 | + $output->writeln($message); |
|
| 199 | + }); |
|
| 200 | + $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use ($output) { |
|
| 201 | + $output->writeln('<info>Updating database schema</info>'); |
|
| 202 | + }); |
|
| 203 | + $updater->listen('\OC\Updater', 'dbUpgrade', function () use ($output) { |
|
| 204 | + $output->writeln('<info>Updated database</info>'); |
|
| 205 | + }); |
|
| 206 | + $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use ($output) { |
|
| 207 | + $output->writeln('<info>Checking whether the database schema can be updated (this can take a long time depending on the database size)</info>'); |
|
| 208 | + }); |
|
| 209 | + $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($output) { |
|
| 210 | + $output->writeln('<info>Checked database schema update</info>'); |
|
| 211 | + }); |
|
| 212 | + $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use ($output) { |
|
| 213 | + $output->writeln('<comment>Disabled incompatible app: ' . $app . '</comment>'); |
|
| 214 | + }); |
|
| 215 | + $updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($output) { |
|
| 216 | + $output->writeln('<info>Checking for update of app ' . $app . ' in appstore</info>'); |
|
| 217 | + }); |
|
| 218 | + $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($output) { |
|
| 219 | + $output->writeln('<info>Update app ' . $app . ' from appstore</info>'); |
|
| 220 | + }); |
|
| 221 | + $updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($output) { |
|
| 222 | + $output->writeln('<info>Checked for update of app "' . $app . '" in appstore </info>'); |
|
| 223 | + }); |
|
| 224 | + $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($output) { |
|
| 225 | + $output->writeln('<info>Checking updates of apps</info>'); |
|
| 226 | + }); |
|
| 227 | + $updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($output) { |
|
| 228 | + $output->writeln("<info>Checking whether the database schema for <$app> can be updated (this can take a long time depending on the database size)</info>"); |
|
| 229 | + }); |
|
| 230 | + $updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($output) { |
|
| 231 | + $output->writeln('<info>Checked database schema update for apps</info>'); |
|
| 232 | + }); |
|
| 233 | + $updater->listen('\OC\Updater', 'appUpgradeStarted', function ($app, $version) use ($output) { |
|
| 234 | + $output->writeln("<info>Updating <$app> ...</info>"); |
|
| 235 | + }); |
|
| 236 | + $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($output) { |
|
| 237 | + $output->writeln("<info>Updated <$app> to $version</info>"); |
|
| 238 | + }); |
|
| 239 | + $updater->listen('\OC\Updater', 'failure', function ($message) use ($output, $self) { |
|
| 240 | + $output->writeln("<error>$message</error>"); |
|
| 241 | + }); |
|
| 242 | + $updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use ($output) { |
|
| 243 | + $output->writeln("<info>Setting log level to debug</info>"); |
|
| 244 | + }); |
|
| 245 | + $updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use ($output) { |
|
| 246 | + $output->writeln("<info>Resetting log level</info>"); |
|
| 247 | + }); |
|
| 248 | + $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use ($output) { |
|
| 249 | + $output->writeln("<info>Starting code integrity check...</info>"); |
|
| 250 | + }); |
|
| 251 | + $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use ($output) { |
|
| 252 | + $output->writeln("<info>Finished code integrity check</info>"); |
|
| 253 | + }); |
|
| 254 | 254 | |
| 255 | - $success = $updater->upgrade(); |
|
| 255 | + $success = $updater->upgrade(); |
|
| 256 | 256 | |
| 257 | - $this->postUpgradeCheck($input, $output); |
|
| 257 | + $this->postUpgradeCheck($input, $output); |
|
| 258 | 258 | |
| 259 | - if (!$success) { |
|
| 260 | - return self::ERROR_FAILURE; |
|
| 261 | - } |
|
| 259 | + if (!$success) { |
|
| 260 | + return self::ERROR_FAILURE; |
|
| 261 | + } |
|
| 262 | 262 | |
| 263 | - return self::ERROR_SUCCESS; |
|
| 264 | - } elseif ($this->config->getSystemValueBool('maintenance')) { |
|
| 265 | - //Possible scenario: Nextcloud core is updated but an app failed |
|
| 266 | - $output->writeln('<warning>Nextcloud is in maintenance mode</warning>'); |
|
| 267 | - $output->write('<comment>Maybe an upgrade is already in process. Please check the ' |
|
| 268 | - . 'logfile (data/nextcloud.log). If you want to re-run the ' |
|
| 269 | - . 'upgrade procedure, remove the "maintenance mode" from ' |
|
| 270 | - . 'config.php and call this script again.</comment>' |
|
| 271 | - , true); |
|
| 272 | - return self::ERROR_MAINTENANCE_MODE; |
|
| 273 | - } else { |
|
| 274 | - $output->writeln('<info>Nextcloud is already latest version</info>'); |
|
| 275 | - return self::ERROR_UP_TO_DATE; |
|
| 276 | - } |
|
| 277 | - } |
|
| 263 | + return self::ERROR_SUCCESS; |
|
| 264 | + } elseif ($this->config->getSystemValueBool('maintenance')) { |
|
| 265 | + //Possible scenario: Nextcloud core is updated but an app failed |
|
| 266 | + $output->writeln('<warning>Nextcloud is in maintenance mode</warning>'); |
|
| 267 | + $output->write('<comment>Maybe an upgrade is already in process. Please check the ' |
|
| 268 | + . 'logfile (data/nextcloud.log). If you want to re-run the ' |
|
| 269 | + . 'upgrade procedure, remove the "maintenance mode" from ' |
|
| 270 | + . 'config.php and call this script again.</comment>' |
|
| 271 | + , true); |
|
| 272 | + return self::ERROR_MAINTENANCE_MODE; |
|
| 273 | + } else { |
|
| 274 | + $output->writeln('<info>Nextcloud is already latest version</info>'); |
|
| 275 | + return self::ERROR_UP_TO_DATE; |
|
| 276 | + } |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | - /** |
|
| 280 | - * Perform a post upgrade check (specific to the command line tool) |
|
| 281 | - * |
|
| 282 | - * @param InputInterface $input input interface |
|
| 283 | - * @param OutputInterface $output output interface |
|
| 284 | - */ |
|
| 285 | - protected function postUpgradeCheck(InputInterface $input, OutputInterface $output) { |
|
| 286 | - $trustedDomains = $this->config->getSystemValue('trusted_domains', []); |
|
| 287 | - if (empty($trustedDomains)) { |
|
| 288 | - $output->write( |
|
| 289 | - '<warning>The setting "trusted_domains" could not be ' . |
|
| 290 | - 'set automatically by the upgrade script, ' . |
|
| 291 | - 'please set it manually</warning>' |
|
| 292 | - ); |
|
| 293 | - } |
|
| 294 | - } |
|
| 279 | + /** |
|
| 280 | + * Perform a post upgrade check (specific to the command line tool) |
|
| 281 | + * |
|
| 282 | + * @param InputInterface $input input interface |
|
| 283 | + * @param OutputInterface $output output interface |
|
| 284 | + */ |
|
| 285 | + protected function postUpgradeCheck(InputInterface $input, OutputInterface $output) { |
|
| 286 | + $trustedDomains = $this->config->getSystemValue('trusted_domains', []); |
|
| 287 | + if (empty($trustedDomains)) { |
|
| 288 | + $output->write( |
|
| 289 | + '<warning>The setting "trusted_domains" could not be ' . |
|
| 290 | + 'set automatically by the upgrade script, ' . |
|
| 291 | + 'please set it manually</warning>' |
|
| 292 | + ); |
|
| 293 | + } |
|
| 294 | + } |
|
| 295 | 295 | } |
@@ -102,14 +102,14 @@ discard block |
||
| 102 | 102 | $dispatcher = \OC::$server->getEventDispatcher(); |
| 103 | 103 | $progress = new ProgressBar($output); |
| 104 | 104 | $progress->setFormat(" %message%\n %current%/%max% [%bar%] %percent:3s%%"); |
| 105 | - $listener = function ($event) use ($progress, $output) { |
|
| 105 | + $listener = function($event) use ($progress, $output) { |
|
| 106 | 106 | if ($event instanceof GenericEvent) { |
| 107 | 107 | $message = $event->getSubject(); |
| 108 | 108 | if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
| 109 | - $output->writeln(' Checking table ' . $message); |
|
| 109 | + $output->writeln(' Checking table '.$message); |
|
| 110 | 110 | } else { |
| 111 | 111 | if (strlen($message) > 60) { |
| 112 | - $message = substr($message, 0, 57) . '...'; |
|
| 112 | + $message = substr($message, 0, 57).'...'; |
|
| 113 | 113 | } |
| 114 | 114 | $progress->setMessage($message); |
| 115 | 115 | if ($event[0] === 1) { |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | }; |
| 128 | - $repairListener = function ($event) use ($progress, $output) { |
|
| 128 | + $repairListener = function($event) use ($progress, $output) { |
|
| 129 | 129 | if (!$event instanceof GenericEvent) { |
| 130 | 130 | return; |
| 131 | 131 | } |
@@ -151,19 +151,19 @@ discard block |
||
| 151 | 151 | break; |
| 152 | 152 | case '\OC\Repair::step': |
| 153 | 153 | if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
| 154 | - $output->writeln('<info>Repair step: ' . $event->getArgument(0) . '</info>'); |
|
| 154 | + $output->writeln('<info>Repair step: '.$event->getArgument(0).'</info>'); |
|
| 155 | 155 | } |
| 156 | 156 | break; |
| 157 | 157 | case '\OC\Repair::info': |
| 158 | 158 | if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
| 159 | - $output->writeln('<info>Repair info: ' . $event->getArgument(0) . '</info>'); |
|
| 159 | + $output->writeln('<info>Repair info: '.$event->getArgument(0).'</info>'); |
|
| 160 | 160 | } |
| 161 | 161 | break; |
| 162 | 162 | case '\OC\Repair::warning': |
| 163 | - $output->writeln('<error>Repair warning: ' . $event->getArgument(0) . '</error>'); |
|
| 163 | + $output->writeln('<error>Repair warning: '.$event->getArgument(0).'</error>'); |
|
| 164 | 164 | break; |
| 165 | 165 | case '\OC\Repair::error': |
| 166 | - $output->writeln('<error>Repair error: ' . $event->getArgument(0) . '</error>'); |
|
| 166 | + $output->writeln('<error>Repair error: '.$event->getArgument(0).'</error>'); |
|
| 167 | 167 | break; |
| 168 | 168 | } |
| 169 | 169 | }; |
@@ -179,17 +179,17 @@ discard block |
||
| 179 | 179 | $dispatcher->addListener('\OC\Repair::error', $repairListener); |
| 180 | 180 | |
| 181 | 181 | |
| 182 | - $updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($output) { |
|
| 182 | + $updater->listen('\OC\Updater', 'maintenanceEnabled', function() use ($output) { |
|
| 183 | 183 | $output->writeln('<info>Turned on maintenance mode</info>'); |
| 184 | 184 | }); |
| 185 | - $updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($output) { |
|
| 185 | + $updater->listen('\OC\Updater', 'maintenanceDisabled', function() use ($output) { |
|
| 186 | 186 | $output->writeln('<info>Turned off maintenance mode</info>'); |
| 187 | 187 | }); |
| 188 | - $updater->listen('\OC\Updater', 'maintenanceActive', function () use ($output) { |
|
| 188 | + $updater->listen('\OC\Updater', 'maintenanceActive', function() use ($output) { |
|
| 189 | 189 | $output->writeln('<info>Maintenance mode is kept active</info>'); |
| 190 | 190 | }); |
| 191 | 191 | $updater->listen('\OC\Updater', 'updateEnd', |
| 192 | - function ($success) use ($output, $self) { |
|
| 192 | + function($success) use ($output, $self) { |
|
| 193 | 193 | if ($success) { |
| 194 | 194 | $message = "<info>Update successful</info>"; |
| 195 | 195 | } else { |
@@ -197,58 +197,58 @@ discard block |
||
| 197 | 197 | } |
| 198 | 198 | $output->writeln($message); |
| 199 | 199 | }); |
| 200 | - $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use ($output) { |
|
| 200 | + $updater->listen('\OC\Updater', 'dbUpgradeBefore', function() use ($output) { |
|
| 201 | 201 | $output->writeln('<info>Updating database schema</info>'); |
| 202 | 202 | }); |
| 203 | - $updater->listen('\OC\Updater', 'dbUpgrade', function () use ($output) { |
|
| 203 | + $updater->listen('\OC\Updater', 'dbUpgrade', function() use ($output) { |
|
| 204 | 204 | $output->writeln('<info>Updated database</info>'); |
| 205 | 205 | }); |
| 206 | - $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use ($output) { |
|
| 206 | + $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function() use ($output) { |
|
| 207 | 207 | $output->writeln('<info>Checking whether the database schema can be updated (this can take a long time depending on the database size)</info>'); |
| 208 | 208 | }); |
| 209 | - $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($output) { |
|
| 209 | + $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function() use ($output) { |
|
| 210 | 210 | $output->writeln('<info>Checked database schema update</info>'); |
| 211 | 211 | }); |
| 212 | - $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use ($output) { |
|
| 213 | - $output->writeln('<comment>Disabled incompatible app: ' . $app . '</comment>'); |
|
| 212 | + $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function($app) use ($output) { |
|
| 213 | + $output->writeln('<comment>Disabled incompatible app: '.$app.'</comment>'); |
|
| 214 | 214 | }); |
| 215 | - $updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($output) { |
|
| 216 | - $output->writeln('<info>Checking for update of app ' . $app . ' in appstore</info>'); |
|
| 215 | + $updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function($app) use ($output) { |
|
| 216 | + $output->writeln('<info>Checking for update of app '.$app.' in appstore</info>'); |
|
| 217 | 217 | }); |
| 218 | - $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($output) { |
|
| 219 | - $output->writeln('<info>Update app ' . $app . ' from appstore</info>'); |
|
| 218 | + $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function($app) use ($output) { |
|
| 219 | + $output->writeln('<info>Update app '.$app.' from appstore</info>'); |
|
| 220 | 220 | }); |
| 221 | - $updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($output) { |
|
| 222 | - $output->writeln('<info>Checked for update of app "' . $app . '" in appstore </info>'); |
|
| 221 | + $updater->listen('\OC\Updater', 'checkAppStoreApp', function($app) use ($output) { |
|
| 222 | + $output->writeln('<info>Checked for update of app "'.$app.'" in appstore </info>'); |
|
| 223 | 223 | }); |
| 224 | - $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($output) { |
|
| 224 | + $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function() use ($output) { |
|
| 225 | 225 | $output->writeln('<info>Checking updates of apps</info>'); |
| 226 | 226 | }); |
| 227 | - $updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($output) { |
|
| 227 | + $updater->listen('\OC\Updater', 'appSimulateUpdate', function($app) use ($output) { |
|
| 228 | 228 | $output->writeln("<info>Checking whether the database schema for <$app> can be updated (this can take a long time depending on the database size)</info>"); |
| 229 | 229 | }); |
| 230 | - $updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($output) { |
|
| 230 | + $updater->listen('\OC\Updater', 'appUpgradeCheck', function() use ($output) { |
|
| 231 | 231 | $output->writeln('<info>Checked database schema update for apps</info>'); |
| 232 | 232 | }); |
| 233 | - $updater->listen('\OC\Updater', 'appUpgradeStarted', function ($app, $version) use ($output) { |
|
| 233 | + $updater->listen('\OC\Updater', 'appUpgradeStarted', function($app, $version) use ($output) { |
|
| 234 | 234 | $output->writeln("<info>Updating <$app> ...</info>"); |
| 235 | 235 | }); |
| 236 | - $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($output) { |
|
| 236 | + $updater->listen('\OC\Updater', 'appUpgrade', function($app, $version) use ($output) { |
|
| 237 | 237 | $output->writeln("<info>Updated <$app> to $version</info>"); |
| 238 | 238 | }); |
| 239 | - $updater->listen('\OC\Updater', 'failure', function ($message) use ($output, $self) { |
|
| 239 | + $updater->listen('\OC\Updater', 'failure', function($message) use ($output, $self) { |
|
| 240 | 240 | $output->writeln("<error>$message</error>"); |
| 241 | 241 | }); |
| 242 | - $updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use ($output) { |
|
| 242 | + $updater->listen('\OC\Updater', 'setDebugLogLevel', function($logLevel, $logLevelName) use ($output) { |
|
| 243 | 243 | $output->writeln("<info>Setting log level to debug</info>"); |
| 244 | 244 | }); |
| 245 | - $updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use ($output) { |
|
| 245 | + $updater->listen('\OC\Updater', 'resetLogLevel', function($logLevel, $logLevelName) use ($output) { |
|
| 246 | 246 | $output->writeln("<info>Resetting log level</info>"); |
| 247 | 247 | }); |
| 248 | - $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use ($output) { |
|
| 248 | + $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function() use ($output) { |
|
| 249 | 249 | $output->writeln("<info>Starting code integrity check...</info>"); |
| 250 | 250 | }); |
| 251 | - $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use ($output) { |
|
| 251 | + $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function() use ($output) { |
|
| 252 | 252 | $output->writeln("<info>Finished code integrity check</info>"); |
| 253 | 253 | }); |
| 254 | 254 | |
@@ -286,8 +286,8 @@ discard block |
||
| 286 | 286 | $trustedDomains = $this->config->getSystemValue('trusted_domains', []); |
| 287 | 287 | if (empty($trustedDomains)) { |
| 288 | 288 | $output->write( |
| 289 | - '<warning>The setting "trusted_domains" could not be ' . |
|
| 290 | - 'set automatically by the upgrade script, ' . |
|
| 289 | + '<warning>The setting "trusted_domains" could not be '. |
|
| 290 | + 'set automatically by the upgrade script, '. |
|
| 291 | 291 | 'please set it manually</warning>' |
| 292 | 292 | ); |
| 293 | 293 | } |