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