@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | use Symfony\Component\EventDispatcher\GenericEvent; |
| 34 | 34 | |
| 35 | 35 | if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
| 36 | - @set_time_limit(0); |
|
| 36 | + @set_time_limit(0); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | require_once '../../lib/base.php'; |
@@ -47,190 +47,190 @@ discard block |
||
| 47 | 47 | $eventSource->send('success', (string)$l->t('Preparing update')); |
| 48 | 48 | |
| 49 | 49 | class FeedBackHandler { |
| 50 | - /** @var integer */ |
|
| 51 | - private $progressStateMax = 100; |
|
| 52 | - /** @var integer */ |
|
| 53 | - private $progressStateStep = 0; |
|
| 54 | - /** @var string */ |
|
| 55 | - private $currentStep; |
|
| 56 | - /** @var \OCP\IEventSource */ |
|
| 57 | - private $eventSource; |
|
| 58 | - /** @var \OCP\IL10N */ |
|
| 59 | - private $l10n; |
|
| 60 | - |
|
| 61 | - public function __construct(\OCP\IEventSource $eventSource, \OCP\IL10N $l10n) { |
|
| 62 | - $this->eventSource = $eventSource; |
|
| 63 | - $this->l10n = $l10n; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - public function handleRepairFeedback($event) { |
|
| 67 | - if (!$event instanceof GenericEvent) { |
|
| 68 | - return; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - switch ($event->getSubject()) { |
|
| 72 | - case '\OC\Repair::startProgress': |
|
| 73 | - $this->progressStateMax = $event->getArgument(0); |
|
| 74 | - $this->progressStateStep = 0; |
|
| 75 | - $this->currentStep = $event->getArgument(1); |
|
| 76 | - break; |
|
| 77 | - case '\OC\Repair::advance': |
|
| 78 | - $this->progressStateStep += $event->getArgument(0); |
|
| 79 | - $desc = $event->getArgument(1); |
|
| 80 | - if (empty($desc)) { |
|
| 81 | - $desc = $this->currentStep; |
|
| 82 | - } |
|
| 83 | - $this->eventSource->send('success', (string)$this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $desc])); |
|
| 84 | - break; |
|
| 85 | - case '\OC\Repair::finishProgress': |
|
| 86 | - $this->progressStateMax = $this->progressStateStep; |
|
| 87 | - $this->eventSource->send('success', (string)$this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $this->currentStep])); |
|
| 88 | - break; |
|
| 89 | - case '\OC\Repair::step': |
|
| 90 | - $this->eventSource->send('success', (string)$this->l10n->t('Repair step:') . ' ' . $event->getArgument(0)); |
|
| 91 | - break; |
|
| 92 | - case '\OC\Repair::info': |
|
| 93 | - $this->eventSource->send('success', (string)$this->l10n->t('Repair info:') . ' ' . $event->getArgument(0)); |
|
| 94 | - break; |
|
| 95 | - case '\OC\Repair::warning': |
|
| 96 | - $this->eventSource->send('notice', (string)$this->l10n->t('Repair warning:') . ' ' . $event->getArgument(0)); |
|
| 97 | - break; |
|
| 98 | - case '\OC\Repair::error': |
|
| 99 | - $this->eventSource->send('notice', (string)$this->l10n->t('Repair error:') . ' ' . $event->getArgument(0)); |
|
| 100 | - break; |
|
| 101 | - } |
|
| 102 | - } |
|
| 50 | + /** @var integer */ |
|
| 51 | + private $progressStateMax = 100; |
|
| 52 | + /** @var integer */ |
|
| 53 | + private $progressStateStep = 0; |
|
| 54 | + /** @var string */ |
|
| 55 | + private $currentStep; |
|
| 56 | + /** @var \OCP\IEventSource */ |
|
| 57 | + private $eventSource; |
|
| 58 | + /** @var \OCP\IL10N */ |
|
| 59 | + private $l10n; |
|
| 60 | + |
|
| 61 | + public function __construct(\OCP\IEventSource $eventSource, \OCP\IL10N $l10n) { |
|
| 62 | + $this->eventSource = $eventSource; |
|
| 63 | + $this->l10n = $l10n; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + public function handleRepairFeedback($event) { |
|
| 67 | + if (!$event instanceof GenericEvent) { |
|
| 68 | + return; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + switch ($event->getSubject()) { |
|
| 72 | + case '\OC\Repair::startProgress': |
|
| 73 | + $this->progressStateMax = $event->getArgument(0); |
|
| 74 | + $this->progressStateStep = 0; |
|
| 75 | + $this->currentStep = $event->getArgument(1); |
|
| 76 | + break; |
|
| 77 | + case '\OC\Repair::advance': |
|
| 78 | + $this->progressStateStep += $event->getArgument(0); |
|
| 79 | + $desc = $event->getArgument(1); |
|
| 80 | + if (empty($desc)) { |
|
| 81 | + $desc = $this->currentStep; |
|
| 82 | + } |
|
| 83 | + $this->eventSource->send('success', (string)$this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $desc])); |
|
| 84 | + break; |
|
| 85 | + case '\OC\Repair::finishProgress': |
|
| 86 | + $this->progressStateMax = $this->progressStateStep; |
|
| 87 | + $this->eventSource->send('success', (string)$this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $this->currentStep])); |
|
| 88 | + break; |
|
| 89 | + case '\OC\Repair::step': |
|
| 90 | + $this->eventSource->send('success', (string)$this->l10n->t('Repair step:') . ' ' . $event->getArgument(0)); |
|
| 91 | + break; |
|
| 92 | + case '\OC\Repair::info': |
|
| 93 | + $this->eventSource->send('success', (string)$this->l10n->t('Repair info:') . ' ' . $event->getArgument(0)); |
|
| 94 | + break; |
|
| 95 | + case '\OC\Repair::warning': |
|
| 96 | + $this->eventSource->send('notice', (string)$this->l10n->t('Repair warning:') . ' ' . $event->getArgument(0)); |
|
| 97 | + break; |
|
| 98 | + case '\OC\Repair::error': |
|
| 99 | + $this->eventSource->send('notice', (string)$this->l10n->t('Repair error:') . ' ' . $event->getArgument(0)); |
|
| 100 | + break; |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | if (\OCP\Util::needUpgrade()) { |
| 106 | 106 | |
| 107 | - $config = \OC::$server->getSystemConfig(); |
|
| 108 | - if ($config->getValue('upgrade.disable-web', false)) { |
|
| 109 | - $eventSource->send('failure', (string)$l->t('Please use the command line updater because automatic updating is disabled in the config.php.')); |
|
| 110 | - $eventSource->close(); |
|
| 111 | - exit(); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - // if a user is currently logged in, their session must be ignored to |
|
| 115 | - // avoid side effects |
|
| 116 | - \OC_User::setIncognitoMode(true); |
|
| 117 | - |
|
| 118 | - $logger = \OC::$server->getLogger(); |
|
| 119 | - $config = \OC::$server->getConfig(); |
|
| 120 | - $updater = new \OC\Updater( |
|
| 121 | - $config, |
|
| 122 | - \OC::$server->getIntegrityCodeChecker(), |
|
| 123 | - $logger, |
|
| 124 | - \OC::$server->query(\OC\Installer::class) |
|
| 125 | - ); |
|
| 126 | - $incompatibleApps = []; |
|
| 127 | - |
|
| 128 | - $dispatcher = \OC::$server->getEventDispatcher(); |
|
| 129 | - $dispatcher->addListener('\OC\DB\Migrator::executeSql', function($event) use ($eventSource, $l) { |
|
| 130 | - if ($event instanceof GenericEvent) { |
|
| 131 | - $eventSource->send('success', (string)$l->t('[%d / %d]: %s', [$event[0], $event[1], $event->getSubject()])); |
|
| 132 | - } |
|
| 133 | - }); |
|
| 134 | - $dispatcher->addListener('\OC\DB\Migrator::checkTable', function($event) use ($eventSource, $l) { |
|
| 135 | - if ($event instanceof GenericEvent) { |
|
| 136 | - $eventSource->send('success', (string)$l->t('[%d / %d]: Checking table %s', [$event[0], $event[1], $event->getSubject()])); |
|
| 137 | - } |
|
| 138 | - }); |
|
| 139 | - $feedBack = new FeedBackHandler($eventSource, $l); |
|
| 140 | - $dispatcher->addListener('\OC\Repair::startProgress', [$feedBack, 'handleRepairFeedback']); |
|
| 141 | - $dispatcher->addListener('\OC\Repair::advance', [$feedBack, 'handleRepairFeedback']); |
|
| 142 | - $dispatcher->addListener('\OC\Repair::finishProgress', [$feedBack, 'handleRepairFeedback']); |
|
| 143 | - $dispatcher->addListener('\OC\Repair::step', [$feedBack, 'handleRepairFeedback']); |
|
| 144 | - $dispatcher->addListener('\OC\Repair::info', [$feedBack, 'handleRepairFeedback']); |
|
| 145 | - $dispatcher->addListener('\OC\Repair::warning', [$feedBack, 'handleRepairFeedback']); |
|
| 146 | - $dispatcher->addListener('\OC\Repair::error', [$feedBack, 'handleRepairFeedback']); |
|
| 147 | - |
|
| 148 | - $updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($eventSource, $l) { |
|
| 149 | - $eventSource->send('success', (string)$l->t('Turned on maintenance mode')); |
|
| 150 | - }); |
|
| 151 | - $updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($eventSource, $l) { |
|
| 152 | - $eventSource->send('success', (string)$l->t('Turned off maintenance mode')); |
|
| 153 | - }); |
|
| 154 | - $updater->listen('\OC\Updater', 'maintenanceActive', function () use ($eventSource, $l) { |
|
| 155 | - $eventSource->send('success', (string)$l->t('Maintenance mode is kept active')); |
|
| 156 | - }); |
|
| 157 | - $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use($eventSource, $l) { |
|
| 158 | - $eventSource->send('success', (string)$l->t('Updating database schema')); |
|
| 159 | - }); |
|
| 160 | - $updater->listen('\OC\Updater', 'dbUpgrade', function () use ($eventSource, $l) { |
|
| 161 | - $eventSource->send('success', (string)$l->t('Updated database')); |
|
| 162 | - }); |
|
| 163 | - $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($eventSource, $l) { |
|
| 164 | - $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)')); |
|
| 165 | - }); |
|
| 166 | - $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($eventSource, $l) { |
|
| 167 | - $eventSource->send('success', (string)$l->t('Checked database schema update')); |
|
| 168 | - }); |
|
| 169 | - $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($eventSource, $l) { |
|
| 170 | - $eventSource->send('success', (string)$l->t('Checking updates of apps')); |
|
| 171 | - }); |
|
| 172 | - $updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($eventSource, $l) { |
|
| 173 | - $eventSource->send('success', (string)$l->t('Checking for update of app "%s" in appstore', [$app])); |
|
| 174 | - }); |
|
| 175 | - $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($eventSource, $l) { |
|
| 176 | - $eventSource->send('success', (string)$l->t('Update app "%s" from appstore', [$app])); |
|
| 177 | - }); |
|
| 178 | - $updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($eventSource, $l) { |
|
| 179 | - $eventSource->send('success', (string)$l->t('Checked for update of app "%s" in appstore', [$app])); |
|
| 180 | - }); |
|
| 181 | - $updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($eventSource, $l) { |
|
| 182 | - $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])); |
|
| 183 | - }); |
|
| 184 | - $updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($eventSource, $l) { |
|
| 185 | - $eventSource->send('success', (string)$l->t('Checked database schema update for apps')); |
|
| 186 | - }); |
|
| 187 | - $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($eventSource, $l) { |
|
| 188 | - $eventSource->send('success', (string)$l->t('Updated "%1$s" to %2$s', array($app, $version))); |
|
| 189 | - }); |
|
| 190 | - $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use (&$incompatibleApps) { |
|
| 191 | - $incompatibleApps[]= $app; |
|
| 192 | - }); |
|
| 193 | - $updater->listen('\OC\Updater', 'failure', function ($message) use ($eventSource, $config) { |
|
| 194 | - $eventSource->send('failure', $message); |
|
| 195 | - $eventSource->close(); |
|
| 196 | - $config->setSystemValue('maintenance', false); |
|
| 197 | - }); |
|
| 198 | - $updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use($eventSource, $l) { |
|
| 199 | - $eventSource->send('success', (string)$l->t('Set log level to debug')); |
|
| 200 | - }); |
|
| 201 | - $updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($eventSource, $l) { |
|
| 202 | - $eventSource->send('success', (string)$l->t('Reset log level')); |
|
| 203 | - }); |
|
| 204 | - $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use($eventSource, $l) { |
|
| 205 | - $eventSource->send('success', (string)$l->t('Starting code integrity check')); |
|
| 206 | - }); |
|
| 207 | - $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use($eventSource, $l) { |
|
| 208 | - $eventSource->send('success', (string)$l->t('Finished code integrity check')); |
|
| 209 | - }); |
|
| 210 | - |
|
| 211 | - try { |
|
| 212 | - $updater->upgrade(); |
|
| 213 | - } catch (\Exception $e) { |
|
| 214 | - \OC::$server->getLogger()->logException($e, [ |
|
| 215 | - 'level' => ILogger::ERROR, |
|
| 216 | - 'app' => 'update', |
|
| 217 | - ]); |
|
| 218 | - $eventSource->send('failure', get_class($e) . ': ' . $e->getMessage()); |
|
| 219 | - $eventSource->close(); |
|
| 220 | - exit(); |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - $disabledApps = []; |
|
| 224 | - foreach ($incompatibleApps as $app) { |
|
| 225 | - $disabledApps[$app] = (string) $l->t('%s (incompatible)', [$app]); |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - if (!empty($disabledApps)) { |
|
| 229 | - $eventSource->send('notice', |
|
| 230 | - (string)$l->t('Following apps have been disabled: %s', [implode(', ', $disabledApps)])); |
|
| 231 | - } |
|
| 107 | + $config = \OC::$server->getSystemConfig(); |
|
| 108 | + if ($config->getValue('upgrade.disable-web', false)) { |
|
| 109 | + $eventSource->send('failure', (string)$l->t('Please use the command line updater because automatic updating is disabled in the config.php.')); |
|
| 110 | + $eventSource->close(); |
|
| 111 | + exit(); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + // if a user is currently logged in, their session must be ignored to |
|
| 115 | + // avoid side effects |
|
| 116 | + \OC_User::setIncognitoMode(true); |
|
| 117 | + |
|
| 118 | + $logger = \OC::$server->getLogger(); |
|
| 119 | + $config = \OC::$server->getConfig(); |
|
| 120 | + $updater = new \OC\Updater( |
|
| 121 | + $config, |
|
| 122 | + \OC::$server->getIntegrityCodeChecker(), |
|
| 123 | + $logger, |
|
| 124 | + \OC::$server->query(\OC\Installer::class) |
|
| 125 | + ); |
|
| 126 | + $incompatibleApps = []; |
|
| 127 | + |
|
| 128 | + $dispatcher = \OC::$server->getEventDispatcher(); |
|
| 129 | + $dispatcher->addListener('\OC\DB\Migrator::executeSql', function($event) use ($eventSource, $l) { |
|
| 130 | + if ($event instanceof GenericEvent) { |
|
| 131 | + $eventSource->send('success', (string)$l->t('[%d / %d]: %s', [$event[0], $event[1], $event->getSubject()])); |
|
| 132 | + } |
|
| 133 | + }); |
|
| 134 | + $dispatcher->addListener('\OC\DB\Migrator::checkTable', function($event) use ($eventSource, $l) { |
|
| 135 | + if ($event instanceof GenericEvent) { |
|
| 136 | + $eventSource->send('success', (string)$l->t('[%d / %d]: Checking table %s', [$event[0], $event[1], $event->getSubject()])); |
|
| 137 | + } |
|
| 138 | + }); |
|
| 139 | + $feedBack = new FeedBackHandler($eventSource, $l); |
|
| 140 | + $dispatcher->addListener('\OC\Repair::startProgress', [$feedBack, 'handleRepairFeedback']); |
|
| 141 | + $dispatcher->addListener('\OC\Repair::advance', [$feedBack, 'handleRepairFeedback']); |
|
| 142 | + $dispatcher->addListener('\OC\Repair::finishProgress', [$feedBack, 'handleRepairFeedback']); |
|
| 143 | + $dispatcher->addListener('\OC\Repair::step', [$feedBack, 'handleRepairFeedback']); |
|
| 144 | + $dispatcher->addListener('\OC\Repair::info', [$feedBack, 'handleRepairFeedback']); |
|
| 145 | + $dispatcher->addListener('\OC\Repair::warning', [$feedBack, 'handleRepairFeedback']); |
|
| 146 | + $dispatcher->addListener('\OC\Repair::error', [$feedBack, 'handleRepairFeedback']); |
|
| 147 | + |
|
| 148 | + $updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($eventSource, $l) { |
|
| 149 | + $eventSource->send('success', (string)$l->t('Turned on maintenance mode')); |
|
| 150 | + }); |
|
| 151 | + $updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($eventSource, $l) { |
|
| 152 | + $eventSource->send('success', (string)$l->t('Turned off maintenance mode')); |
|
| 153 | + }); |
|
| 154 | + $updater->listen('\OC\Updater', 'maintenanceActive', function () use ($eventSource, $l) { |
|
| 155 | + $eventSource->send('success', (string)$l->t('Maintenance mode is kept active')); |
|
| 156 | + }); |
|
| 157 | + $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use($eventSource, $l) { |
|
| 158 | + $eventSource->send('success', (string)$l->t('Updating database schema')); |
|
| 159 | + }); |
|
| 160 | + $updater->listen('\OC\Updater', 'dbUpgrade', function () use ($eventSource, $l) { |
|
| 161 | + $eventSource->send('success', (string)$l->t('Updated database')); |
|
| 162 | + }); |
|
| 163 | + $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($eventSource, $l) { |
|
| 164 | + $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)')); |
|
| 165 | + }); |
|
| 166 | + $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($eventSource, $l) { |
|
| 167 | + $eventSource->send('success', (string)$l->t('Checked database schema update')); |
|
| 168 | + }); |
|
| 169 | + $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($eventSource, $l) { |
|
| 170 | + $eventSource->send('success', (string)$l->t('Checking updates of apps')); |
|
| 171 | + }); |
|
| 172 | + $updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($eventSource, $l) { |
|
| 173 | + $eventSource->send('success', (string)$l->t('Checking for update of app "%s" in appstore', [$app])); |
|
| 174 | + }); |
|
| 175 | + $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($eventSource, $l) { |
|
| 176 | + $eventSource->send('success', (string)$l->t('Update app "%s" from appstore', [$app])); |
|
| 177 | + }); |
|
| 178 | + $updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($eventSource, $l) { |
|
| 179 | + $eventSource->send('success', (string)$l->t('Checked for update of app "%s" in appstore', [$app])); |
|
| 180 | + }); |
|
| 181 | + $updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($eventSource, $l) { |
|
| 182 | + $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])); |
|
| 183 | + }); |
|
| 184 | + $updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($eventSource, $l) { |
|
| 185 | + $eventSource->send('success', (string)$l->t('Checked database schema update for apps')); |
|
| 186 | + }); |
|
| 187 | + $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($eventSource, $l) { |
|
| 188 | + $eventSource->send('success', (string)$l->t('Updated "%1$s" to %2$s', array($app, $version))); |
|
| 189 | + }); |
|
| 190 | + $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use (&$incompatibleApps) { |
|
| 191 | + $incompatibleApps[]= $app; |
|
| 192 | + }); |
|
| 193 | + $updater->listen('\OC\Updater', 'failure', function ($message) use ($eventSource, $config) { |
|
| 194 | + $eventSource->send('failure', $message); |
|
| 195 | + $eventSource->close(); |
|
| 196 | + $config->setSystemValue('maintenance', false); |
|
| 197 | + }); |
|
| 198 | + $updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use($eventSource, $l) { |
|
| 199 | + $eventSource->send('success', (string)$l->t('Set log level to debug')); |
|
| 200 | + }); |
|
| 201 | + $updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($eventSource, $l) { |
|
| 202 | + $eventSource->send('success', (string)$l->t('Reset log level')); |
|
| 203 | + }); |
|
| 204 | + $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use($eventSource, $l) { |
|
| 205 | + $eventSource->send('success', (string)$l->t('Starting code integrity check')); |
|
| 206 | + }); |
|
| 207 | + $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use($eventSource, $l) { |
|
| 208 | + $eventSource->send('success', (string)$l->t('Finished code integrity check')); |
|
| 209 | + }); |
|
| 210 | + |
|
| 211 | + try { |
|
| 212 | + $updater->upgrade(); |
|
| 213 | + } catch (\Exception $e) { |
|
| 214 | + \OC::$server->getLogger()->logException($e, [ |
|
| 215 | + 'level' => ILogger::ERROR, |
|
| 216 | + 'app' => 'update', |
|
| 217 | + ]); |
|
| 218 | + $eventSource->send('failure', get_class($e) . ': ' . $e->getMessage()); |
|
| 219 | + $eventSource->close(); |
|
| 220 | + exit(); |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + $disabledApps = []; |
|
| 224 | + foreach ($incompatibleApps as $app) { |
|
| 225 | + $disabledApps[$app] = (string) $l->t('%s (incompatible)', [$app]); |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + if (!empty($disabledApps)) { |
|
| 229 | + $eventSource->send('notice', |
|
| 230 | + (string)$l->t('Following apps have been disabled: %s', [implode(', ', $disabledApps)])); |
|
| 231 | + } |
|
| 232 | 232 | } else { |
| 233 | - $eventSource->send('notice', (string)$l->t('Already up to date')); |
|
| 233 | + $eventSource->send('notice', (string)$l->t('Already up to date')); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | $eventSource->send('done', ''); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | // need to send an initial message to force-init the event source, |
| 45 | 45 | // which will then trigger its own CSRF check and produces its own CSRF error |
| 46 | 46 | // message |
| 47 | -$eventSource->send('success', (string)$l->t('Preparing update')); |
|
| 47 | +$eventSource->send('success', (string) $l->t('Preparing update')); |
|
| 48 | 48 | |
| 49 | 49 | class FeedBackHandler { |
| 50 | 50 | /** @var integer */ |
@@ -80,23 +80,23 @@ discard block |
||
| 80 | 80 | if (empty($desc)) { |
| 81 | 81 | $desc = $this->currentStep; |
| 82 | 82 | } |
| 83 | - $this->eventSource->send('success', (string)$this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $desc])); |
|
| 83 | + $this->eventSource->send('success', (string) $this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $desc])); |
|
| 84 | 84 | break; |
| 85 | 85 | case '\OC\Repair::finishProgress': |
| 86 | 86 | $this->progressStateMax = $this->progressStateStep; |
| 87 | - $this->eventSource->send('success', (string)$this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $this->currentStep])); |
|
| 87 | + $this->eventSource->send('success', (string) $this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $this->currentStep])); |
|
| 88 | 88 | break; |
| 89 | 89 | case '\OC\Repair::step': |
| 90 | - $this->eventSource->send('success', (string)$this->l10n->t('Repair step:') . ' ' . $event->getArgument(0)); |
|
| 90 | + $this->eventSource->send('success', (string) $this->l10n->t('Repair step:').' '.$event->getArgument(0)); |
|
| 91 | 91 | break; |
| 92 | 92 | case '\OC\Repair::info': |
| 93 | - $this->eventSource->send('success', (string)$this->l10n->t('Repair info:') . ' ' . $event->getArgument(0)); |
|
| 93 | + $this->eventSource->send('success', (string) $this->l10n->t('Repair info:').' '.$event->getArgument(0)); |
|
| 94 | 94 | break; |
| 95 | 95 | case '\OC\Repair::warning': |
| 96 | - $this->eventSource->send('notice', (string)$this->l10n->t('Repair warning:') . ' ' . $event->getArgument(0)); |
|
| 96 | + $this->eventSource->send('notice', (string) $this->l10n->t('Repair warning:').' '.$event->getArgument(0)); |
|
| 97 | 97 | break; |
| 98 | 98 | case '\OC\Repair::error': |
| 99 | - $this->eventSource->send('notice', (string)$this->l10n->t('Repair error:') . ' ' . $event->getArgument(0)); |
|
| 99 | + $this->eventSource->send('notice', (string) $this->l10n->t('Repair error:').' '.$event->getArgument(0)); |
|
| 100 | 100 | break; |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | $config = \OC::$server->getSystemConfig(); |
| 108 | 108 | if ($config->getValue('upgrade.disable-web', false)) { |
| 109 | - $eventSource->send('failure', (string)$l->t('Please use the command line updater because automatic updating is disabled in the config.php.')); |
|
| 109 | + $eventSource->send('failure', (string) $l->t('Please use the command line updater because automatic updating is disabled in the config.php.')); |
|
| 110 | 110 | $eventSource->close(); |
| 111 | 111 | exit(); |
| 112 | 112 | } |
@@ -128,12 +128,12 @@ discard block |
||
| 128 | 128 | $dispatcher = \OC::$server->getEventDispatcher(); |
| 129 | 129 | $dispatcher->addListener('\OC\DB\Migrator::executeSql', function($event) use ($eventSource, $l) { |
| 130 | 130 | if ($event instanceof GenericEvent) { |
| 131 | - $eventSource->send('success', (string)$l->t('[%d / %d]: %s', [$event[0], $event[1], $event->getSubject()])); |
|
| 131 | + $eventSource->send('success', (string) $l->t('[%d / %d]: %s', [$event[0], $event[1], $event->getSubject()])); |
|
| 132 | 132 | } |
| 133 | 133 | }); |
| 134 | 134 | $dispatcher->addListener('\OC\DB\Migrator::checkTable', function($event) use ($eventSource, $l) { |
| 135 | 135 | if ($event instanceof GenericEvent) { |
| 136 | - $eventSource->send('success', (string)$l->t('[%d / %d]: Checking table %s', [$event[0], $event[1], $event->getSubject()])); |
|
| 136 | + $eventSource->send('success', (string) $l->t('[%d / %d]: Checking table %s', [$event[0], $event[1], $event->getSubject()])); |
|
| 137 | 137 | } |
| 138 | 138 | }); |
| 139 | 139 | $feedBack = new FeedBackHandler($eventSource, $l); |
@@ -145,67 +145,67 @@ discard block |
||
| 145 | 145 | $dispatcher->addListener('\OC\Repair::warning', [$feedBack, 'handleRepairFeedback']); |
| 146 | 146 | $dispatcher->addListener('\OC\Repair::error', [$feedBack, 'handleRepairFeedback']); |
| 147 | 147 | |
| 148 | - $updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($eventSource, $l) { |
|
| 149 | - $eventSource->send('success', (string)$l->t('Turned on maintenance mode')); |
|
| 148 | + $updater->listen('\OC\Updater', 'maintenanceEnabled', function() use ($eventSource, $l) { |
|
| 149 | + $eventSource->send('success', (string) $l->t('Turned on maintenance mode')); |
|
| 150 | 150 | }); |
| 151 | - $updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($eventSource, $l) { |
|
| 152 | - $eventSource->send('success', (string)$l->t('Turned off maintenance mode')); |
|
| 151 | + $updater->listen('\OC\Updater', 'maintenanceDisabled', function() use ($eventSource, $l) { |
|
| 152 | + $eventSource->send('success', (string) $l->t('Turned off maintenance mode')); |
|
| 153 | 153 | }); |
| 154 | - $updater->listen('\OC\Updater', 'maintenanceActive', function () use ($eventSource, $l) { |
|
| 155 | - $eventSource->send('success', (string)$l->t('Maintenance mode is kept active')); |
|
| 154 | + $updater->listen('\OC\Updater', 'maintenanceActive', function() use ($eventSource, $l) { |
|
| 155 | + $eventSource->send('success', (string) $l->t('Maintenance mode is kept active')); |
|
| 156 | 156 | }); |
| 157 | - $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use($eventSource, $l) { |
|
| 158 | - $eventSource->send('success', (string)$l->t('Updating database schema')); |
|
| 157 | + $updater->listen('\OC\Updater', 'dbUpgradeBefore', function() use($eventSource, $l) { |
|
| 158 | + $eventSource->send('success', (string) $l->t('Updating database schema')); |
|
| 159 | 159 | }); |
| 160 | - $updater->listen('\OC\Updater', 'dbUpgrade', function () use ($eventSource, $l) { |
|
| 161 | - $eventSource->send('success', (string)$l->t('Updated database')); |
|
| 160 | + $updater->listen('\OC\Updater', 'dbUpgrade', function() use ($eventSource, $l) { |
|
| 161 | + $eventSource->send('success', (string) $l->t('Updated database')); |
|
| 162 | 162 | }); |
| 163 | - $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($eventSource, $l) { |
|
| 164 | - $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)')); |
|
| 163 | + $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function() use($eventSource, $l) { |
|
| 164 | + $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)')); |
|
| 165 | 165 | }); |
| 166 | - $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($eventSource, $l) { |
|
| 167 | - $eventSource->send('success', (string)$l->t('Checked database schema update')); |
|
| 166 | + $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function() use ($eventSource, $l) { |
|
| 167 | + $eventSource->send('success', (string) $l->t('Checked database schema update')); |
|
| 168 | 168 | }); |
| 169 | - $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($eventSource, $l) { |
|
| 170 | - $eventSource->send('success', (string)$l->t('Checking updates of apps')); |
|
| 169 | + $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function() use ($eventSource, $l) { |
|
| 170 | + $eventSource->send('success', (string) $l->t('Checking updates of apps')); |
|
| 171 | 171 | }); |
| 172 | - $updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($eventSource, $l) { |
|
| 173 | - $eventSource->send('success', (string)$l->t('Checking for update of app "%s" in appstore', [$app])); |
|
| 172 | + $updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function($app) use ($eventSource, $l) { |
|
| 173 | + $eventSource->send('success', (string) $l->t('Checking for update of app "%s" in appstore', [$app])); |
|
| 174 | 174 | }); |
| 175 | - $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($eventSource, $l) { |
|
| 176 | - $eventSource->send('success', (string)$l->t('Update app "%s" from appstore', [$app])); |
|
| 175 | + $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function($app) use ($eventSource, $l) { |
|
| 176 | + $eventSource->send('success', (string) $l->t('Update app "%s" from appstore', [$app])); |
|
| 177 | 177 | }); |
| 178 | - $updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($eventSource, $l) { |
|
| 179 | - $eventSource->send('success', (string)$l->t('Checked for update of app "%s" in appstore', [$app])); |
|
| 178 | + $updater->listen('\OC\Updater', 'checkAppStoreApp', function($app) use ($eventSource, $l) { |
|
| 179 | + $eventSource->send('success', (string) $l->t('Checked for update of app "%s" in appstore', [$app])); |
|
| 180 | 180 | }); |
| 181 | - $updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($eventSource, $l) { |
|
| 182 | - $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])); |
|
| 181 | + $updater->listen('\OC\Updater', 'appSimulateUpdate', function($app) use ($eventSource, $l) { |
|
| 182 | + $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])); |
|
| 183 | 183 | }); |
| 184 | - $updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($eventSource, $l) { |
|
| 185 | - $eventSource->send('success', (string)$l->t('Checked database schema update for apps')); |
|
| 184 | + $updater->listen('\OC\Updater', 'appUpgradeCheck', function() use ($eventSource, $l) { |
|
| 185 | + $eventSource->send('success', (string) $l->t('Checked database schema update for apps')); |
|
| 186 | 186 | }); |
| 187 | - $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($eventSource, $l) { |
|
| 188 | - $eventSource->send('success', (string)$l->t('Updated "%1$s" to %2$s', array($app, $version))); |
|
| 187 | + $updater->listen('\OC\Updater', 'appUpgrade', function($app, $version) use ($eventSource, $l) { |
|
| 188 | + $eventSource->send('success', (string) $l->t('Updated "%1$s" to %2$s', array($app, $version))); |
|
| 189 | 189 | }); |
| 190 | - $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use (&$incompatibleApps) { |
|
| 191 | - $incompatibleApps[]= $app; |
|
| 190 | + $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function($app) use (&$incompatibleApps) { |
|
| 191 | + $incompatibleApps[] = $app; |
|
| 192 | 192 | }); |
| 193 | - $updater->listen('\OC\Updater', 'failure', function ($message) use ($eventSource, $config) { |
|
| 193 | + $updater->listen('\OC\Updater', 'failure', function($message) use ($eventSource, $config) { |
|
| 194 | 194 | $eventSource->send('failure', $message); |
| 195 | 195 | $eventSource->close(); |
| 196 | 196 | $config->setSystemValue('maintenance', false); |
| 197 | 197 | }); |
| 198 | - $updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use($eventSource, $l) { |
|
| 199 | - $eventSource->send('success', (string)$l->t('Set log level to debug')); |
|
| 198 | + $updater->listen('\OC\Updater', 'setDebugLogLevel', function($logLevel, $logLevelName) use($eventSource, $l) { |
|
| 199 | + $eventSource->send('success', (string) $l->t('Set log level to debug')); |
|
| 200 | 200 | }); |
| 201 | - $updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($eventSource, $l) { |
|
| 202 | - $eventSource->send('success', (string)$l->t('Reset log level')); |
|
| 201 | + $updater->listen('\OC\Updater', 'resetLogLevel', function($logLevel, $logLevelName) use($eventSource, $l) { |
|
| 202 | + $eventSource->send('success', (string) $l->t('Reset log level')); |
|
| 203 | 203 | }); |
| 204 | - $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use($eventSource, $l) { |
|
| 205 | - $eventSource->send('success', (string)$l->t('Starting code integrity check')); |
|
| 204 | + $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function() use($eventSource, $l) { |
|
| 205 | + $eventSource->send('success', (string) $l->t('Starting code integrity check')); |
|
| 206 | 206 | }); |
| 207 | - $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use($eventSource, $l) { |
|
| 208 | - $eventSource->send('success', (string)$l->t('Finished code integrity check')); |
|
| 207 | + $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function() use($eventSource, $l) { |
|
| 208 | + $eventSource->send('success', (string) $l->t('Finished code integrity check')); |
|
| 209 | 209 | }); |
| 210 | 210 | |
| 211 | 211 | try { |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | 'level' => ILogger::ERROR, |
| 216 | 216 | 'app' => 'update', |
| 217 | 217 | ]); |
| 218 | - $eventSource->send('failure', get_class($e) . ': ' . $e->getMessage()); |
|
| 218 | + $eventSource->send('failure', get_class($e).': '.$e->getMessage()); |
|
| 219 | 219 | $eventSource->close(); |
| 220 | 220 | exit(); |
| 221 | 221 | } |
@@ -227,10 +227,10 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | if (!empty($disabledApps)) { |
| 229 | 229 | $eventSource->send('notice', |
| 230 | - (string)$l->t('Following apps have been disabled: %s', [implode(', ', $disabledApps)])); |
|
| 230 | + (string) $l->t('Following apps have been disabled: %s', [implode(', ', $disabledApps)])); |
|
| 231 | 231 | } |
| 232 | 232 | } else { |
| 233 | - $eventSource->send('notice', (string)$l->t('Already up to date')); |
|
| 233 | + $eventSource->send('notice', (string) $l->t('Already up to date')); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | $eventSource->send('done', ''); |