Completed
Push — master ( 23b6f0...d83f1d )
by Lukas
27s
created
lib/private/Updater.php 2 patches
Indentation   +570 added lines, -570 removed lines patch added patch discarded remove patch
@@ -51,576 +51,576 @@
 block discarded – undo
51 51
  */
52 52
 class Updater extends BasicEmitter {
53 53
 
54
-	/** @var ILogger $log */
55
-	private $log;
56
-
57
-	/** @var IConfig */
58
-	private $config;
59
-
60
-	/** @var Checker */
61
-	private $checker;
62
-
63
-	/** @var bool */
64
-	private $skip3rdPartyAppsDisable;
65
-
66
-	private $logLevelNames = [
67
-		0 => 'Debug',
68
-		1 => 'Info',
69
-		2 => 'Warning',
70
-		3 => 'Error',
71
-		4 => 'Fatal',
72
-	];
73
-
74
-	/**
75
-	 * @param IConfig $config
76
-	 * @param Checker $checker
77
-	 * @param ILogger $log
78
-	 */
79
-	public function __construct(IConfig $config,
80
-								Checker $checker,
81
-								ILogger $log = null) {
82
-		$this->log = $log;
83
-		$this->config = $config;
84
-		$this->checker = $checker;
85
-
86
-		// If at least PHP 7.0.0 is used we don't need to disable apps as we catch
87
-		// fatal errors and exceptions and disable the app just instead.
88
-		if(version_compare(phpversion(), '7.0.0', '>=')) {
89
-			$this->skip3rdPartyAppsDisable = true;
90
-		}
91
-	}
92
-
93
-	/**
94
-	 * Sets whether the update disables 3rd party apps.
95
-	 * This can be set to true to skip the disable.
96
-	 *
97
-	 * @param bool $flag false to not disable, true otherwise
98
-	 */
99
-	public function setSkip3rdPartyAppsDisable($flag) {
100
-		$this->skip3rdPartyAppsDisable = $flag;
101
-	}
102
-
103
-	/**
104
-	 * runs the update actions in maintenance mode, does not upgrade the source files
105
-	 * except the main .htaccess file
106
-	 *
107
-	 * @return bool true if the operation succeeded, false otherwise
108
-	 */
109
-	public function upgrade() {
110
-		$this->emitRepairEvents();
111
-		$this->logAllEvents();
112
-
113
-		$logLevel = $this->config->getSystemValue('loglevel', Util::WARN);
114
-		$this->emit('\OC\Updater', 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]);
115
-		$this->config->setSystemValue('loglevel', Util::DEBUG);
116
-
117
-		$wasMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false);
118
-
119
-		if(!$wasMaintenanceModeEnabled) {
120
-			$this->config->setSystemValue('maintenance', true);
121
-			$this->emit('\OC\Updater', 'maintenanceEnabled');
122
-		}
123
-
124
-		$installedVersion = $this->config->getSystemValue('version', '0.0.0');
125
-		$currentVersion = implode('.', \OCP\Util::getVersion());
126
-		$this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core'));
127
-
128
-		$success = true;
129
-		try {
130
-			$this->doUpgrade($currentVersion, $installedVersion);
131
-		} catch (HintException $exception) {
132
-			$this->log->logException($exception, ['app' => 'core']);
133
-			$this->emit('\OC\Updater', 'failure', array($exception->getMessage() . ': ' .$exception->getHint()));
134
-			$success = false;
135
-		} catch (\Exception $exception) {
136
-			$this->log->logException($exception, ['app' => 'core']);
137
-			$this->emit('\OC\Updater', 'failure', array(get_class($exception) . ': ' .$exception->getMessage()));
138
-			$success = false;
139
-		}
140
-
141
-		$this->emit('\OC\Updater', 'updateEnd', array($success));
142
-
143
-		if(!$wasMaintenanceModeEnabled && $success) {
144
-			$this->config->setSystemValue('maintenance', false);
145
-			$this->emit('\OC\Updater', 'maintenanceDisabled');
146
-		} else {
147
-			$this->emit('\OC\Updater', 'maintenanceActive');
148
-		}
149
-
150
-		$this->emit('\OC\Updater', 'resetLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]);
151
-		$this->config->setSystemValue('loglevel', $logLevel);
152
-		$this->config->setSystemValue('installed', true);
153
-
154
-		return $success;
155
-	}
156
-
157
-	/**
158
-	 * Return version from which this version is allowed to upgrade from
159
-	 *
160
-	 * @return array allowed previous versions per vendor
161
-	 */
162
-	private function getAllowedPreviousVersions() {
163
-		// this should really be a JSON file
164
-		require \OC::$SERVERROOT . '/version.php';
165
-		/** @var array $OC_VersionCanBeUpgradedFrom */
166
-		return $OC_VersionCanBeUpgradedFrom;
167
-	}
168
-
169
-	/**
170
-	 * Return vendor from which this version was published
171
-	 *
172
-	 * @return string Get the vendor
173
-	 */
174
-	private function getVendor() {
175
-		// this should really be a JSON file
176
-		require \OC::$SERVERROOT . '/version.php';
177
-		/** @var string $vendor */
178
-		return (string) $vendor;
179
-	}
180
-
181
-	/**
182
-	 * Whether an upgrade to a specified version is possible
183
-	 * @param string $oldVersion
184
-	 * @param string $newVersion
185
-	 * @param array $allowedPreviousVersions
186
-	 * @return bool
187
-	 */
188
-	public function isUpgradePossible($oldVersion, $newVersion, array $allowedPreviousVersions) {
189
-		$version = explode('.', $oldVersion);
190
-		$majorMinor = $version[0] . '.' . $version[1];
191
-
192
-		$currentVendor = $this->config->getAppValue('core', 'vendor', '');
193
-		if ($currentVendor === 'nextcloud') {
194
-			return isset($allowedPreviousVersions[$currentVendor][$majorMinor])
195
-				&& (version_compare($oldVersion, $newVersion, '<=') ||
196
-					$this->config->getSystemValue('debug', false));
197
-		}
198
-
199
-		// Check if the instance can be migrated
200
-		return isset($allowedPreviousVersions[$currentVendor][$majorMinor]);
201
-	}
202
-
203
-	/**
204
-	 * runs the update actions in maintenance mode, does not upgrade the source files
205
-	 * except the main .htaccess file
206
-	 *
207
-	 * @param string $currentVersion current version to upgrade to
208
-	 * @param string $installedVersion previous version from which to upgrade from
209
-	 *
210
-	 * @throws \Exception
211
-	 */
212
-	private function doUpgrade($currentVersion, $installedVersion) {
213
-		// Stop update if the update is over several major versions
214
-		$allowedPreviousVersions = $this->getAllowedPreviousVersions();
215
-		if (!$this->isUpgradePossible($installedVersion, $currentVersion, $allowedPreviousVersions)) {
216
-			throw new \Exception('Updates between multiple major versions and downgrades are unsupported.');
217
-		}
218
-
219
-		// Update .htaccess files
220
-		try {
221
-			Setup::updateHtaccess();
222
-			Setup::protectDataDirectory();
223
-		} catch (\Exception $e) {
224
-			throw new \Exception($e->getMessage());
225
-		}
226
-
227
-		// create empty file in data dir, so we can later find
228
-		// out that this is indeed an ownCloud data directory
229
-		// (in case it didn't exist before)
230
-		file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
231
-
232
-		// pre-upgrade repairs
233
-		$repair = new Repair(Repair::getBeforeUpgradeRepairSteps(), \OC::$server->getEventDispatcher());
234
-		$repair->run();
235
-
236
-		$this->doCoreUpgrade();
237
-
238
-		try {
239
-			// TODO: replace with the new repair step mechanism https://github.com/owncloud/core/pull/24378
240
-			Setup::installBackgroundJobs();
241
-		} catch (\Exception $e) {
242
-			throw new \Exception($e->getMessage());
243
-		}
244
-
245
-		// update all shipped apps
246
-		$this->checkAppsRequirements();
247
-		$this->doAppUpgrade();
248
-
249
-		// Update the appfetchers version so it downloads the correct list from the appstore
250
-		\OC::$server->getAppFetcher()->setVersion($currentVersion);
251
-
252
-		// upgrade appstore apps
253
-		$this->upgradeAppStoreApps(\OC::$server->getAppManager()->getInstalledApps());
254
-
255
-		// install new shipped apps on upgrade
256
-		OC_App::loadApps('authentication');
257
-		$errors = Installer::installShippedApps(true);
258
-		foreach ($errors as $appId => $exception) {
259
-			/** @var \Exception $exception */
260
-			$this->log->logException($exception, ['app' => $appId]);
261
-			$this->emit('\OC\Updater', 'failure', [$appId . ': ' . $exception->getMessage()]);
262
-		}
263
-
264
-		// post-upgrade repairs
265
-		$repair = new Repair(Repair::getRepairSteps(), \OC::$server->getEventDispatcher());
266
-		$repair->run();
267
-
268
-		//Invalidate update feed
269
-		$this->config->setAppValue('core', 'lastupdatedat', 0);
270
-
271
-		// Check for code integrity if not disabled
272
-		if(\OC::$server->getIntegrityCodeChecker()->isCodeCheckEnforced()) {
273
-			$this->emit('\OC\Updater', 'startCheckCodeIntegrity');
274
-			$this->checker->runInstanceVerification();
275
-			$this->emit('\OC\Updater', 'finishedCheckCodeIntegrity');
276
-		}
277
-
278
-		// only set the final version if everything went well
279
-		$this->config->setSystemValue('version', implode('.', Util::getVersion()));
280
-		$this->config->setAppValue('core', 'vendor', $this->getVendor());
281
-	}
282
-
283
-	protected function doCoreUpgrade() {
284
-		$this->emit('\OC\Updater', 'dbUpgradeBefore');
285
-
286
-		// do the real upgrade
287
-		\OC_DB::updateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml');
288
-
289
-		$this->emit('\OC\Updater', 'dbUpgrade');
290
-	}
291
-
292
-	/**
293
-	 * @param string $version the oc version to check app compatibility with
294
-	 */
295
-	protected function checkAppUpgrade($version) {
296
-		$apps = \OC_App::getEnabledApps();
297
-		$this->emit('\OC\Updater', 'appUpgradeCheckBefore');
298
-
299
-		foreach ($apps as $appId) {
300
-			$info = \OC_App::getAppInfo($appId);
301
-			$compatible = \OC_App::isAppCompatible($version, $info);
302
-			$isShipped = \OC_App::isShipped($appId);
303
-
304
-			if ($compatible && $isShipped && \OC_App::shouldUpgrade($appId)) {
305
-				/**
306
-				 * FIXME: The preupdate check is performed before the database migration, otherwise database changes
307
-				 * are not possible anymore within it. - Consider this when touching the code.
308
-				 * @link https://github.com/owncloud/core/issues/10980
309
-				 * @see \OC_App::updateApp
310
-				 */
311
-				if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/preupdate.php')) {
312
-					$this->includePreUpdate($appId);
313
-				}
314
-				if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/database.xml')) {
315
-					$this->emit('\OC\Updater', 'appSimulateUpdate', array($appId));
316
-					\OC_DB::simulateUpdateDbFromStructure(\OC_App::getAppPath($appId) . '/appinfo/database.xml');
317
-				}
318
-			}
319
-		}
320
-
321
-		$this->emit('\OC\Updater', 'appUpgradeCheck');
322
-	}
323
-
324
-	/**
325
-	 * Includes the pre-update file. Done here to prevent namespace mixups.
326
-	 * @param string $appId
327
-	 */
328
-	private function includePreUpdate($appId) {
329
-		include \OC_App::getAppPath($appId) . '/appinfo/preupdate.php';
330
-	}
331
-
332
-	/**
333
-	 * upgrades all apps within a major ownCloud upgrade. Also loads "priority"
334
-	 * (types authentication, filesystem, logging, in that order) afterwards.
335
-	 *
336
-	 * @throws NeedsUpdateException
337
-	 */
338
-	protected function doAppUpgrade() {
339
-		$apps = \OC_App::getEnabledApps();
340
-		$priorityTypes = array('authentication', 'filesystem', 'logging');
341
-		$pseudoOtherType = 'other';
342
-		$stacks = array($pseudoOtherType => array());
343
-
344
-		foreach ($apps as $appId) {
345
-			$priorityType = false;
346
-			foreach ($priorityTypes as $type) {
347
-				if(!isset($stacks[$type])) {
348
-					$stacks[$type] = array();
349
-				}
350
-				if (\OC_App::isType($appId, $type)) {
351
-					$stacks[$type][] = $appId;
352
-					$priorityType = true;
353
-					break;
354
-				}
355
-			}
356
-			if (!$priorityType) {
357
-				$stacks[$pseudoOtherType][] = $appId;
358
-			}
359
-		}
360
-		foreach ($stacks as $type => $stack) {
361
-			foreach ($stack as $appId) {
362
-				if (\OC_App::shouldUpgrade($appId)) {
363
-					$this->emit('\OC\Updater', 'appUpgradeStarted', [$appId, \OC_App::getAppVersion($appId)]);
364
-					\OC_App::updateApp($appId);
365
-					$this->emit('\OC\Updater', 'appUpgrade', [$appId, \OC_App::getAppVersion($appId)]);
366
-				}
367
-				if($type !== $pseudoOtherType) {
368
-					// load authentication, filesystem and logging apps after
369
-					// upgrading them. Other apps my need to rely on modifying
370
-					// user and/or filesystem aspects.
371
-					\OC_App::loadApp($appId);
372
-				}
373
-			}
374
-		}
375
-	}
376
-
377
-	/**
378
-	 * check if the current enabled apps are compatible with the current
379
-	 * ownCloud version. disable them if not.
380
-	 * This is important if you upgrade ownCloud and have non ported 3rd
381
-	 * party apps installed.
382
-	 *
383
-	 * @return array
384
-	 * @throws \Exception
385
-	 */
386
-	private function checkAppsRequirements() {
387
-		$isCoreUpgrade = $this->isCodeUpgrade();
388
-		$apps = OC_App::getEnabledApps();
389
-		$version = Util::getVersion();
390
-		$disabledApps = [];
391
-		foreach ($apps as $app) {
392
-			// check if the app is compatible with this version of ownCloud
393
-			$info = OC_App::getAppInfo($app);
394
-			if(!OC_App::isAppCompatible($version, $info)) {
395
-				if (OC_App::isShipped($app)) {
396
-					throw new \UnexpectedValueException('The files of the app "' . $app . '" were not correctly replaced before running the update');
397
-				}
398
-				OC_App::disable($app);
399
-				$this->emit('\OC\Updater', 'incompatibleAppDisabled', array($app));
400
-			}
401
-			// no need to disable any app in case this is a non-core upgrade
402
-			if (!$isCoreUpgrade) {
403
-				continue;
404
-			}
405
-			// shipped apps will remain enabled
406
-			if (OC_App::isShipped($app)) {
407
-				continue;
408
-			}
409
-			// authentication and session apps will remain enabled as well
410
-			if (OC_App::isType($app, ['session', 'authentication'])) {
411
-				continue;
412
-			}
413
-
414
-			// disable any other 3rd party apps if not overriden
415
-			if(!$this->skip3rdPartyAppsDisable) {
416
-				\OC_App::disable($app);
417
-				$disabledApps[]= $app;
418
-				$this->emit('\OC\Updater', 'thirdPartyAppDisabled', array($app));
419
-			};
420
-		}
421
-		return $disabledApps;
422
-	}
423
-
424
-	/**
425
-	 * @return bool
426
-	 */
427
-	private function isCodeUpgrade() {
428
-		$installedVersion = $this->config->getSystemValue('version', '0.0.0');
429
-		$currentVersion = implode('.', Util::getVersion());
430
-		if (version_compare($currentVersion, $installedVersion, '>')) {
431
-			return true;
432
-		}
433
-		return false;
434
-	}
435
-
436
-	/**
437
-	 * @param array $disabledApps
438
-	 * @throws \Exception
439
-	 */
440
-	private function upgradeAppStoreApps(array $disabledApps) {
441
-		foreach($disabledApps as $app) {
442
-			try {
443
-				$installer = new Installer(
444
-					\OC::$server->getAppFetcher(),
445
-					\OC::$server->getHTTPClientService(),
446
-					\OC::$server->getTempManager(),
447
-					$this->log,
448
-					\OC::$server->getConfig()
449
-				);
450
-				$this->emit('\OC\Updater', 'checkAppStoreAppBefore', [$app]);
451
-				if (Installer::isUpdateAvailable($app, \OC::$server->getAppFetcher())) {
452
-					$this->emit('\OC\Updater', 'upgradeAppStoreApp', [$app]);
453
-					$installer->updateAppstoreApp($app);
454
-				}
455
-				$this->emit('\OC\Updater', 'checkAppStoreApp', [$app]);
456
-			} catch (\Exception $ex) {
457
-				$this->log->logException($ex, ['app' => 'core']);
458
-			}
459
-		}
460
-	}
461
-
462
-	/**
463
-	 * Forward messages emitted by the repair routine
464
-	 */
465
-	private function emitRepairEvents() {
466
-		$dispatcher = \OC::$server->getEventDispatcher();
467
-		$dispatcher->addListener('\OC\Repair::warning', function ($event) {
468
-			if ($event instanceof GenericEvent) {
469
-				$this->emit('\OC\Updater', 'repairWarning', $event->getArguments());
470
-			}
471
-		});
472
-		$dispatcher->addListener('\OC\Repair::error', function ($event) {
473
-			if ($event instanceof GenericEvent) {
474
-				$this->emit('\OC\Updater', 'repairError', $event->getArguments());
475
-			}
476
-		});
477
-		$dispatcher->addListener('\OC\Repair::info', function ($event) {
478
-			if ($event instanceof GenericEvent) {
479
-				$this->emit('\OC\Updater', 'repairInfo', $event->getArguments());
480
-			}
481
-		});
482
-		$dispatcher->addListener('\OC\Repair::step', function ($event) {
483
-			if ($event instanceof GenericEvent) {
484
-				$this->emit('\OC\Updater', 'repairStep', $event->getArguments());
485
-			}
486
-		});
487
-	}
488
-
489
-	private function logAllEvents() {
490
-		$log = $this->log;
491
-
492
-		$dispatcher = \OC::$server->getEventDispatcher();
493
-		$dispatcher->addListener('\OC\DB\Migrator::executeSql', function($event) use ($log) {
494
-			if (!$event instanceof GenericEvent) {
495
-				return;
496
-			}
497
-			$log->info('\OC\DB\Migrator::executeSql: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']);
498
-		});
499
-		$dispatcher->addListener('\OC\DB\Migrator::checkTable', function($event) use ($log) {
500
-			if (!$event instanceof GenericEvent) {
501
-				return;
502
-			}
503
-			$log->info('\OC\DB\Migrator::checkTable: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']);
504
-		});
505
-
506
-		$repairListener = function($event) use ($log) {
507
-			if (!$event instanceof GenericEvent) {
508
-				return;
509
-			}
510
-			switch ($event->getSubject()) {
511
-				case '\OC\Repair::startProgress':
512
-					$log->info('\OC\Repair::startProgress: Starting ... ' . $event->getArgument(1) .  ' (' . $event->getArgument(0) . ')', ['app' => 'updater']);
513
-					break;
514
-				case '\OC\Repair::advance':
515
-					$desc = $event->getArgument(1);
516
-					if (empty($desc)) {
517
-						$desc = '';
518
-					}
519
-					$log->info('\OC\Repair::advance: ' . $desc . ' (' . $event->getArgument(0) . ')', ['app' => 'updater']);
520
-
521
-					break;
522
-				case '\OC\Repair::finishProgress':
523
-					$log->info('\OC\Repair::finishProgress', ['app' => 'updater']);
524
-					break;
525
-				case '\OC\Repair::step':
526
-					$log->info('\OC\Repair::step: Repair step: ' . $event->getArgument(0), ['app' => 'updater']);
527
-					break;
528
-				case '\OC\Repair::info':
529
-					$log->info('\OC\Repair::info: Repair info: ' . $event->getArgument(0), ['app' => 'updater']);
530
-					break;
531
-				case '\OC\Repair::warning':
532
-					$log->warning('\OC\Repair::warning: Repair warning: ' . $event->getArgument(0), ['app' => 'updater']);
533
-					break;
534
-				case '\OC\Repair::error':
535
-					$log->error('\OC\Repair::error: Repair error: ' . $event->getArgument(0), ['app' => 'updater']);
536
-					break;
537
-			}
538
-		};
539
-
540
-		$dispatcher->addListener('\OC\Repair::startProgress', $repairListener);
541
-		$dispatcher->addListener('\OC\Repair::advance', $repairListener);
542
-		$dispatcher->addListener('\OC\Repair::finishProgress', $repairListener);
543
-		$dispatcher->addListener('\OC\Repair::step', $repairListener);
544
-		$dispatcher->addListener('\OC\Repair::info', $repairListener);
545
-		$dispatcher->addListener('\OC\Repair::warning', $repairListener);
546
-		$dispatcher->addListener('\OC\Repair::error', $repairListener);
547
-
548
-
549
-		$this->listen('\OC\Updater', 'maintenanceEnabled', function () use($log) {
550
-			$log->info('\OC\Updater::maintenanceEnabled: Turned on maintenance mode', ['app' => 'updater']);
551
-		});
552
-		$this->listen('\OC\Updater', 'maintenanceDisabled', function () use($log) {
553
-			$log->info('\OC\Updater::maintenanceDisabled: Turned off maintenance mode', ['app' => 'updater']);
554
-		});
555
-		$this->listen('\OC\Updater', 'maintenanceActive', function () use($log) {
556
-			$log->info('\OC\Updater::maintenanceActive: Maintenance mode is kept active', ['app' => 'updater']);
557
-		});
558
-		$this->listen('\OC\Updater', 'updateEnd', function ($success) use($log) {
559
-			if ($success) {
560
-				$log->info('\OC\Updater::updateEnd: Update successful', ['app' => 'updater']);
561
-			} else {
562
-				$log->error('\OC\Updater::updateEnd: Update failed', ['app' => 'updater']);
563
-			}
564
-		});
565
-		$this->listen('\OC\Updater', 'dbUpgradeBefore', function () use($log) {
566
-			$log->info('\OC\Updater::dbUpgradeBefore: Updating database schema', ['app' => 'updater']);
567
-		});
568
-		$this->listen('\OC\Updater', 'dbUpgrade', function () use($log) {
569
-			$log->info('\OC\Updater::dbUpgrade: Updated database', ['app' => 'updater']);
570
-		});
571
-		$this->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($log) {
572
-			$log->info('\OC\Updater::dbSimulateUpgradeBefore: Checking whether the database schema can be updated (this can take a long time depending on the database size)', ['app' => 'updater']);
573
-		});
574
-		$this->listen('\OC\Updater', 'dbSimulateUpgrade', function () use($log) {
575
-			$log->info('\OC\Updater::dbSimulateUpgrade: Checked database schema update', ['app' => 'updater']);
576
-		});
577
-		$this->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use($log) {
578
-			$log->info('\OC\Updater::incompatibleAppDisabled: Disabled incompatible app: ' . $app, ['app' => 'updater']);
579
-		});
580
-		$this->listen('\OC\Updater', 'thirdPartyAppDisabled', function ($app) use ($log) {
581
-			$log->info('\OC\Updater::thirdPartyAppDisabled: Disabled 3rd-party app: ' . $app, ['app' => 'updater']);
582
-		});
583
-		$this->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use($log) {
584
-			$log->info('\OC\Updater::checkAppStoreAppBefore: Checking for update of app "' . $app . '" in appstore', ['app' => 'updater']);
585
-		});
586
-		$this->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use($log) {
587
-			$log->info('\OC\Updater::upgradeAppStoreApp: Update app "' . $app . '" from appstore', ['app' => 'updater']);
588
-		});
589
-		$this->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use($log) {
590
-			$log->info('\OC\Updater::checkAppStoreApp: Checked for update of app "' . $app . '" in appstore', ['app' => 'updater']);
591
-		});
592
-		$this->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($log) {
593
-			$log->info('\OC\Updater::appUpgradeCheckBefore: Checking updates of apps', ['app' => 'updater']);
594
-		});
595
-		$this->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($log) {
596
-			$log->info('\OC\Updater::appSimulateUpdate: Checking whether the database schema for <' . $app . '> can be updated (this can take a long time depending on the database size)', ['app' => 'updater']);
597
-		});
598
-		$this->listen('\OC\Updater', 'appUpgradeCheck', function () use ($log) {
599
-			$log->info('\OC\Updater::appUpgradeCheck: Checked database schema update for apps', ['app' => 'updater']);
600
-		});
601
-		$this->listen('\OC\Updater', 'appUpgradeStarted', function ($app) use ($log) {
602
-			$log->info('\OC\Updater::appUpgradeStarted: Updating <' . $app . '> ...', ['app' => 'updater']);
603
-		});
604
-		$this->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($log) {
605
-			$log->info('\OC\Updater::appUpgrade: Updated <' . $app . '> to ' . $version, ['app' => 'updater']);
606
-		});
607
-		$this->listen('\OC\Updater', 'failure', function ($message) use($log) {
608
-			$log->error('\OC\Updater::failure: ' . $message, ['app' => 'updater']);
609
-		});
610
-		$this->listen('\OC\Updater', 'setDebugLogLevel', function () use($log) {
611
-			$log->info('\OC\Updater::setDebugLogLevel: Set log level to debug', ['app' => 'updater']);
612
-		});
613
-		$this->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($log) {
614
-			$log->info('\OC\Updater::resetLogLevel: Reset log level to ' . $logLevelName . '(' . $logLevel . ')', ['app' => 'updater']);
615
-		});
616
-		$this->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use($log) {
617
-			$log->info('\OC\Updater::startCheckCodeIntegrity: Starting code integrity check...', ['app' => 'updater']);
618
-		});
619
-		$this->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use($log) {
620
-			$log->info('\OC\Updater::finishedCheckCodeIntegrity: Finished code integrity check', ['app' => 'updater']);
621
-		});
622
-
623
-	}
54
+    /** @var ILogger $log */
55
+    private $log;
56
+
57
+    /** @var IConfig */
58
+    private $config;
59
+
60
+    /** @var Checker */
61
+    private $checker;
62
+
63
+    /** @var bool */
64
+    private $skip3rdPartyAppsDisable;
65
+
66
+    private $logLevelNames = [
67
+        0 => 'Debug',
68
+        1 => 'Info',
69
+        2 => 'Warning',
70
+        3 => 'Error',
71
+        4 => 'Fatal',
72
+    ];
73
+
74
+    /**
75
+     * @param IConfig $config
76
+     * @param Checker $checker
77
+     * @param ILogger $log
78
+     */
79
+    public function __construct(IConfig $config,
80
+                                Checker $checker,
81
+                                ILogger $log = null) {
82
+        $this->log = $log;
83
+        $this->config = $config;
84
+        $this->checker = $checker;
85
+
86
+        // If at least PHP 7.0.0 is used we don't need to disable apps as we catch
87
+        // fatal errors and exceptions and disable the app just instead.
88
+        if(version_compare(phpversion(), '7.0.0', '>=')) {
89
+            $this->skip3rdPartyAppsDisable = true;
90
+        }
91
+    }
92
+
93
+    /**
94
+     * Sets whether the update disables 3rd party apps.
95
+     * This can be set to true to skip the disable.
96
+     *
97
+     * @param bool $flag false to not disable, true otherwise
98
+     */
99
+    public function setSkip3rdPartyAppsDisable($flag) {
100
+        $this->skip3rdPartyAppsDisable = $flag;
101
+    }
102
+
103
+    /**
104
+     * runs the update actions in maintenance mode, does not upgrade the source files
105
+     * except the main .htaccess file
106
+     *
107
+     * @return bool true if the operation succeeded, false otherwise
108
+     */
109
+    public function upgrade() {
110
+        $this->emitRepairEvents();
111
+        $this->logAllEvents();
112
+
113
+        $logLevel = $this->config->getSystemValue('loglevel', Util::WARN);
114
+        $this->emit('\OC\Updater', 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]);
115
+        $this->config->setSystemValue('loglevel', Util::DEBUG);
116
+
117
+        $wasMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false);
118
+
119
+        if(!$wasMaintenanceModeEnabled) {
120
+            $this->config->setSystemValue('maintenance', true);
121
+            $this->emit('\OC\Updater', 'maintenanceEnabled');
122
+        }
123
+
124
+        $installedVersion = $this->config->getSystemValue('version', '0.0.0');
125
+        $currentVersion = implode('.', \OCP\Util::getVersion());
126
+        $this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core'));
127
+
128
+        $success = true;
129
+        try {
130
+            $this->doUpgrade($currentVersion, $installedVersion);
131
+        } catch (HintException $exception) {
132
+            $this->log->logException($exception, ['app' => 'core']);
133
+            $this->emit('\OC\Updater', 'failure', array($exception->getMessage() . ': ' .$exception->getHint()));
134
+            $success = false;
135
+        } catch (\Exception $exception) {
136
+            $this->log->logException($exception, ['app' => 'core']);
137
+            $this->emit('\OC\Updater', 'failure', array(get_class($exception) . ': ' .$exception->getMessage()));
138
+            $success = false;
139
+        }
140
+
141
+        $this->emit('\OC\Updater', 'updateEnd', array($success));
142
+
143
+        if(!$wasMaintenanceModeEnabled && $success) {
144
+            $this->config->setSystemValue('maintenance', false);
145
+            $this->emit('\OC\Updater', 'maintenanceDisabled');
146
+        } else {
147
+            $this->emit('\OC\Updater', 'maintenanceActive');
148
+        }
149
+
150
+        $this->emit('\OC\Updater', 'resetLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]);
151
+        $this->config->setSystemValue('loglevel', $logLevel);
152
+        $this->config->setSystemValue('installed', true);
153
+
154
+        return $success;
155
+    }
156
+
157
+    /**
158
+     * Return version from which this version is allowed to upgrade from
159
+     *
160
+     * @return array allowed previous versions per vendor
161
+     */
162
+    private function getAllowedPreviousVersions() {
163
+        // this should really be a JSON file
164
+        require \OC::$SERVERROOT . '/version.php';
165
+        /** @var array $OC_VersionCanBeUpgradedFrom */
166
+        return $OC_VersionCanBeUpgradedFrom;
167
+    }
168
+
169
+    /**
170
+     * Return vendor from which this version was published
171
+     *
172
+     * @return string Get the vendor
173
+     */
174
+    private function getVendor() {
175
+        // this should really be a JSON file
176
+        require \OC::$SERVERROOT . '/version.php';
177
+        /** @var string $vendor */
178
+        return (string) $vendor;
179
+    }
180
+
181
+    /**
182
+     * Whether an upgrade to a specified version is possible
183
+     * @param string $oldVersion
184
+     * @param string $newVersion
185
+     * @param array $allowedPreviousVersions
186
+     * @return bool
187
+     */
188
+    public function isUpgradePossible($oldVersion, $newVersion, array $allowedPreviousVersions) {
189
+        $version = explode('.', $oldVersion);
190
+        $majorMinor = $version[0] . '.' . $version[1];
191
+
192
+        $currentVendor = $this->config->getAppValue('core', 'vendor', '');
193
+        if ($currentVendor === 'nextcloud') {
194
+            return isset($allowedPreviousVersions[$currentVendor][$majorMinor])
195
+                && (version_compare($oldVersion, $newVersion, '<=') ||
196
+                    $this->config->getSystemValue('debug', false));
197
+        }
198
+
199
+        // Check if the instance can be migrated
200
+        return isset($allowedPreviousVersions[$currentVendor][$majorMinor]);
201
+    }
202
+
203
+    /**
204
+     * runs the update actions in maintenance mode, does not upgrade the source files
205
+     * except the main .htaccess file
206
+     *
207
+     * @param string $currentVersion current version to upgrade to
208
+     * @param string $installedVersion previous version from which to upgrade from
209
+     *
210
+     * @throws \Exception
211
+     */
212
+    private function doUpgrade($currentVersion, $installedVersion) {
213
+        // Stop update if the update is over several major versions
214
+        $allowedPreviousVersions = $this->getAllowedPreviousVersions();
215
+        if (!$this->isUpgradePossible($installedVersion, $currentVersion, $allowedPreviousVersions)) {
216
+            throw new \Exception('Updates between multiple major versions and downgrades are unsupported.');
217
+        }
218
+
219
+        // Update .htaccess files
220
+        try {
221
+            Setup::updateHtaccess();
222
+            Setup::protectDataDirectory();
223
+        } catch (\Exception $e) {
224
+            throw new \Exception($e->getMessage());
225
+        }
226
+
227
+        // create empty file in data dir, so we can later find
228
+        // out that this is indeed an ownCloud data directory
229
+        // (in case it didn't exist before)
230
+        file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
231
+
232
+        // pre-upgrade repairs
233
+        $repair = new Repair(Repair::getBeforeUpgradeRepairSteps(), \OC::$server->getEventDispatcher());
234
+        $repair->run();
235
+
236
+        $this->doCoreUpgrade();
237
+
238
+        try {
239
+            // TODO: replace with the new repair step mechanism https://github.com/owncloud/core/pull/24378
240
+            Setup::installBackgroundJobs();
241
+        } catch (\Exception $e) {
242
+            throw new \Exception($e->getMessage());
243
+        }
244
+
245
+        // update all shipped apps
246
+        $this->checkAppsRequirements();
247
+        $this->doAppUpgrade();
248
+
249
+        // Update the appfetchers version so it downloads the correct list from the appstore
250
+        \OC::$server->getAppFetcher()->setVersion($currentVersion);
251
+
252
+        // upgrade appstore apps
253
+        $this->upgradeAppStoreApps(\OC::$server->getAppManager()->getInstalledApps());
254
+
255
+        // install new shipped apps on upgrade
256
+        OC_App::loadApps('authentication');
257
+        $errors = Installer::installShippedApps(true);
258
+        foreach ($errors as $appId => $exception) {
259
+            /** @var \Exception $exception */
260
+            $this->log->logException($exception, ['app' => $appId]);
261
+            $this->emit('\OC\Updater', 'failure', [$appId . ': ' . $exception->getMessage()]);
262
+        }
263
+
264
+        // post-upgrade repairs
265
+        $repair = new Repair(Repair::getRepairSteps(), \OC::$server->getEventDispatcher());
266
+        $repair->run();
267
+
268
+        //Invalidate update feed
269
+        $this->config->setAppValue('core', 'lastupdatedat', 0);
270
+
271
+        // Check for code integrity if not disabled
272
+        if(\OC::$server->getIntegrityCodeChecker()->isCodeCheckEnforced()) {
273
+            $this->emit('\OC\Updater', 'startCheckCodeIntegrity');
274
+            $this->checker->runInstanceVerification();
275
+            $this->emit('\OC\Updater', 'finishedCheckCodeIntegrity');
276
+        }
277
+
278
+        // only set the final version if everything went well
279
+        $this->config->setSystemValue('version', implode('.', Util::getVersion()));
280
+        $this->config->setAppValue('core', 'vendor', $this->getVendor());
281
+    }
282
+
283
+    protected function doCoreUpgrade() {
284
+        $this->emit('\OC\Updater', 'dbUpgradeBefore');
285
+
286
+        // do the real upgrade
287
+        \OC_DB::updateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml');
288
+
289
+        $this->emit('\OC\Updater', 'dbUpgrade');
290
+    }
291
+
292
+    /**
293
+     * @param string $version the oc version to check app compatibility with
294
+     */
295
+    protected function checkAppUpgrade($version) {
296
+        $apps = \OC_App::getEnabledApps();
297
+        $this->emit('\OC\Updater', 'appUpgradeCheckBefore');
298
+
299
+        foreach ($apps as $appId) {
300
+            $info = \OC_App::getAppInfo($appId);
301
+            $compatible = \OC_App::isAppCompatible($version, $info);
302
+            $isShipped = \OC_App::isShipped($appId);
303
+
304
+            if ($compatible && $isShipped && \OC_App::shouldUpgrade($appId)) {
305
+                /**
306
+                 * FIXME: The preupdate check is performed before the database migration, otherwise database changes
307
+                 * are not possible anymore within it. - Consider this when touching the code.
308
+                 * @link https://github.com/owncloud/core/issues/10980
309
+                 * @see \OC_App::updateApp
310
+                 */
311
+                if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/preupdate.php')) {
312
+                    $this->includePreUpdate($appId);
313
+                }
314
+                if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/database.xml')) {
315
+                    $this->emit('\OC\Updater', 'appSimulateUpdate', array($appId));
316
+                    \OC_DB::simulateUpdateDbFromStructure(\OC_App::getAppPath($appId) . '/appinfo/database.xml');
317
+                }
318
+            }
319
+        }
320
+
321
+        $this->emit('\OC\Updater', 'appUpgradeCheck');
322
+    }
323
+
324
+    /**
325
+     * Includes the pre-update file. Done here to prevent namespace mixups.
326
+     * @param string $appId
327
+     */
328
+    private function includePreUpdate($appId) {
329
+        include \OC_App::getAppPath($appId) . '/appinfo/preupdate.php';
330
+    }
331
+
332
+    /**
333
+     * upgrades all apps within a major ownCloud upgrade. Also loads "priority"
334
+     * (types authentication, filesystem, logging, in that order) afterwards.
335
+     *
336
+     * @throws NeedsUpdateException
337
+     */
338
+    protected function doAppUpgrade() {
339
+        $apps = \OC_App::getEnabledApps();
340
+        $priorityTypes = array('authentication', 'filesystem', 'logging');
341
+        $pseudoOtherType = 'other';
342
+        $stacks = array($pseudoOtherType => array());
343
+
344
+        foreach ($apps as $appId) {
345
+            $priorityType = false;
346
+            foreach ($priorityTypes as $type) {
347
+                if(!isset($stacks[$type])) {
348
+                    $stacks[$type] = array();
349
+                }
350
+                if (\OC_App::isType($appId, $type)) {
351
+                    $stacks[$type][] = $appId;
352
+                    $priorityType = true;
353
+                    break;
354
+                }
355
+            }
356
+            if (!$priorityType) {
357
+                $stacks[$pseudoOtherType][] = $appId;
358
+            }
359
+        }
360
+        foreach ($stacks as $type => $stack) {
361
+            foreach ($stack as $appId) {
362
+                if (\OC_App::shouldUpgrade($appId)) {
363
+                    $this->emit('\OC\Updater', 'appUpgradeStarted', [$appId, \OC_App::getAppVersion($appId)]);
364
+                    \OC_App::updateApp($appId);
365
+                    $this->emit('\OC\Updater', 'appUpgrade', [$appId, \OC_App::getAppVersion($appId)]);
366
+                }
367
+                if($type !== $pseudoOtherType) {
368
+                    // load authentication, filesystem and logging apps after
369
+                    // upgrading them. Other apps my need to rely on modifying
370
+                    // user and/or filesystem aspects.
371
+                    \OC_App::loadApp($appId);
372
+                }
373
+            }
374
+        }
375
+    }
376
+
377
+    /**
378
+     * check if the current enabled apps are compatible with the current
379
+     * ownCloud version. disable them if not.
380
+     * This is important if you upgrade ownCloud and have non ported 3rd
381
+     * party apps installed.
382
+     *
383
+     * @return array
384
+     * @throws \Exception
385
+     */
386
+    private function checkAppsRequirements() {
387
+        $isCoreUpgrade = $this->isCodeUpgrade();
388
+        $apps = OC_App::getEnabledApps();
389
+        $version = Util::getVersion();
390
+        $disabledApps = [];
391
+        foreach ($apps as $app) {
392
+            // check if the app is compatible with this version of ownCloud
393
+            $info = OC_App::getAppInfo($app);
394
+            if(!OC_App::isAppCompatible($version, $info)) {
395
+                if (OC_App::isShipped($app)) {
396
+                    throw new \UnexpectedValueException('The files of the app "' . $app . '" were not correctly replaced before running the update');
397
+                }
398
+                OC_App::disable($app);
399
+                $this->emit('\OC\Updater', 'incompatibleAppDisabled', array($app));
400
+            }
401
+            // no need to disable any app in case this is a non-core upgrade
402
+            if (!$isCoreUpgrade) {
403
+                continue;
404
+            }
405
+            // shipped apps will remain enabled
406
+            if (OC_App::isShipped($app)) {
407
+                continue;
408
+            }
409
+            // authentication and session apps will remain enabled as well
410
+            if (OC_App::isType($app, ['session', 'authentication'])) {
411
+                continue;
412
+            }
413
+
414
+            // disable any other 3rd party apps if not overriden
415
+            if(!$this->skip3rdPartyAppsDisable) {
416
+                \OC_App::disable($app);
417
+                $disabledApps[]= $app;
418
+                $this->emit('\OC\Updater', 'thirdPartyAppDisabled', array($app));
419
+            };
420
+        }
421
+        return $disabledApps;
422
+    }
423
+
424
+    /**
425
+     * @return bool
426
+     */
427
+    private function isCodeUpgrade() {
428
+        $installedVersion = $this->config->getSystemValue('version', '0.0.0');
429
+        $currentVersion = implode('.', Util::getVersion());
430
+        if (version_compare($currentVersion, $installedVersion, '>')) {
431
+            return true;
432
+        }
433
+        return false;
434
+    }
435
+
436
+    /**
437
+     * @param array $disabledApps
438
+     * @throws \Exception
439
+     */
440
+    private function upgradeAppStoreApps(array $disabledApps) {
441
+        foreach($disabledApps as $app) {
442
+            try {
443
+                $installer = new Installer(
444
+                    \OC::$server->getAppFetcher(),
445
+                    \OC::$server->getHTTPClientService(),
446
+                    \OC::$server->getTempManager(),
447
+                    $this->log,
448
+                    \OC::$server->getConfig()
449
+                );
450
+                $this->emit('\OC\Updater', 'checkAppStoreAppBefore', [$app]);
451
+                if (Installer::isUpdateAvailable($app, \OC::$server->getAppFetcher())) {
452
+                    $this->emit('\OC\Updater', 'upgradeAppStoreApp', [$app]);
453
+                    $installer->updateAppstoreApp($app);
454
+                }
455
+                $this->emit('\OC\Updater', 'checkAppStoreApp', [$app]);
456
+            } catch (\Exception $ex) {
457
+                $this->log->logException($ex, ['app' => 'core']);
458
+            }
459
+        }
460
+    }
461
+
462
+    /**
463
+     * Forward messages emitted by the repair routine
464
+     */
465
+    private function emitRepairEvents() {
466
+        $dispatcher = \OC::$server->getEventDispatcher();
467
+        $dispatcher->addListener('\OC\Repair::warning', function ($event) {
468
+            if ($event instanceof GenericEvent) {
469
+                $this->emit('\OC\Updater', 'repairWarning', $event->getArguments());
470
+            }
471
+        });
472
+        $dispatcher->addListener('\OC\Repair::error', function ($event) {
473
+            if ($event instanceof GenericEvent) {
474
+                $this->emit('\OC\Updater', 'repairError', $event->getArguments());
475
+            }
476
+        });
477
+        $dispatcher->addListener('\OC\Repair::info', function ($event) {
478
+            if ($event instanceof GenericEvent) {
479
+                $this->emit('\OC\Updater', 'repairInfo', $event->getArguments());
480
+            }
481
+        });
482
+        $dispatcher->addListener('\OC\Repair::step', function ($event) {
483
+            if ($event instanceof GenericEvent) {
484
+                $this->emit('\OC\Updater', 'repairStep', $event->getArguments());
485
+            }
486
+        });
487
+    }
488
+
489
+    private function logAllEvents() {
490
+        $log = $this->log;
491
+
492
+        $dispatcher = \OC::$server->getEventDispatcher();
493
+        $dispatcher->addListener('\OC\DB\Migrator::executeSql', function($event) use ($log) {
494
+            if (!$event instanceof GenericEvent) {
495
+                return;
496
+            }
497
+            $log->info('\OC\DB\Migrator::executeSql: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']);
498
+        });
499
+        $dispatcher->addListener('\OC\DB\Migrator::checkTable', function($event) use ($log) {
500
+            if (!$event instanceof GenericEvent) {
501
+                return;
502
+            }
503
+            $log->info('\OC\DB\Migrator::checkTable: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']);
504
+        });
505
+
506
+        $repairListener = function($event) use ($log) {
507
+            if (!$event instanceof GenericEvent) {
508
+                return;
509
+            }
510
+            switch ($event->getSubject()) {
511
+                case '\OC\Repair::startProgress':
512
+                    $log->info('\OC\Repair::startProgress: Starting ... ' . $event->getArgument(1) .  ' (' . $event->getArgument(0) . ')', ['app' => 'updater']);
513
+                    break;
514
+                case '\OC\Repair::advance':
515
+                    $desc = $event->getArgument(1);
516
+                    if (empty($desc)) {
517
+                        $desc = '';
518
+                    }
519
+                    $log->info('\OC\Repair::advance: ' . $desc . ' (' . $event->getArgument(0) . ')', ['app' => 'updater']);
520
+
521
+                    break;
522
+                case '\OC\Repair::finishProgress':
523
+                    $log->info('\OC\Repair::finishProgress', ['app' => 'updater']);
524
+                    break;
525
+                case '\OC\Repair::step':
526
+                    $log->info('\OC\Repair::step: Repair step: ' . $event->getArgument(0), ['app' => 'updater']);
527
+                    break;
528
+                case '\OC\Repair::info':
529
+                    $log->info('\OC\Repair::info: Repair info: ' . $event->getArgument(0), ['app' => 'updater']);
530
+                    break;
531
+                case '\OC\Repair::warning':
532
+                    $log->warning('\OC\Repair::warning: Repair warning: ' . $event->getArgument(0), ['app' => 'updater']);
533
+                    break;
534
+                case '\OC\Repair::error':
535
+                    $log->error('\OC\Repair::error: Repair error: ' . $event->getArgument(0), ['app' => 'updater']);
536
+                    break;
537
+            }
538
+        };
539
+
540
+        $dispatcher->addListener('\OC\Repair::startProgress', $repairListener);
541
+        $dispatcher->addListener('\OC\Repair::advance', $repairListener);
542
+        $dispatcher->addListener('\OC\Repair::finishProgress', $repairListener);
543
+        $dispatcher->addListener('\OC\Repair::step', $repairListener);
544
+        $dispatcher->addListener('\OC\Repair::info', $repairListener);
545
+        $dispatcher->addListener('\OC\Repair::warning', $repairListener);
546
+        $dispatcher->addListener('\OC\Repair::error', $repairListener);
547
+
548
+
549
+        $this->listen('\OC\Updater', 'maintenanceEnabled', function () use($log) {
550
+            $log->info('\OC\Updater::maintenanceEnabled: Turned on maintenance mode', ['app' => 'updater']);
551
+        });
552
+        $this->listen('\OC\Updater', 'maintenanceDisabled', function () use($log) {
553
+            $log->info('\OC\Updater::maintenanceDisabled: Turned off maintenance mode', ['app' => 'updater']);
554
+        });
555
+        $this->listen('\OC\Updater', 'maintenanceActive', function () use($log) {
556
+            $log->info('\OC\Updater::maintenanceActive: Maintenance mode is kept active', ['app' => 'updater']);
557
+        });
558
+        $this->listen('\OC\Updater', 'updateEnd', function ($success) use($log) {
559
+            if ($success) {
560
+                $log->info('\OC\Updater::updateEnd: Update successful', ['app' => 'updater']);
561
+            } else {
562
+                $log->error('\OC\Updater::updateEnd: Update failed', ['app' => 'updater']);
563
+            }
564
+        });
565
+        $this->listen('\OC\Updater', 'dbUpgradeBefore', function () use($log) {
566
+            $log->info('\OC\Updater::dbUpgradeBefore: Updating database schema', ['app' => 'updater']);
567
+        });
568
+        $this->listen('\OC\Updater', 'dbUpgrade', function () use($log) {
569
+            $log->info('\OC\Updater::dbUpgrade: Updated database', ['app' => 'updater']);
570
+        });
571
+        $this->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($log) {
572
+            $log->info('\OC\Updater::dbSimulateUpgradeBefore: Checking whether the database schema can be updated (this can take a long time depending on the database size)', ['app' => 'updater']);
573
+        });
574
+        $this->listen('\OC\Updater', 'dbSimulateUpgrade', function () use($log) {
575
+            $log->info('\OC\Updater::dbSimulateUpgrade: Checked database schema update', ['app' => 'updater']);
576
+        });
577
+        $this->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use($log) {
578
+            $log->info('\OC\Updater::incompatibleAppDisabled: Disabled incompatible app: ' . $app, ['app' => 'updater']);
579
+        });
580
+        $this->listen('\OC\Updater', 'thirdPartyAppDisabled', function ($app) use ($log) {
581
+            $log->info('\OC\Updater::thirdPartyAppDisabled: Disabled 3rd-party app: ' . $app, ['app' => 'updater']);
582
+        });
583
+        $this->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use($log) {
584
+            $log->info('\OC\Updater::checkAppStoreAppBefore: Checking for update of app "' . $app . '" in appstore', ['app' => 'updater']);
585
+        });
586
+        $this->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use($log) {
587
+            $log->info('\OC\Updater::upgradeAppStoreApp: Update app "' . $app . '" from appstore', ['app' => 'updater']);
588
+        });
589
+        $this->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use($log) {
590
+            $log->info('\OC\Updater::checkAppStoreApp: Checked for update of app "' . $app . '" in appstore', ['app' => 'updater']);
591
+        });
592
+        $this->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($log) {
593
+            $log->info('\OC\Updater::appUpgradeCheckBefore: Checking updates of apps', ['app' => 'updater']);
594
+        });
595
+        $this->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($log) {
596
+            $log->info('\OC\Updater::appSimulateUpdate: Checking whether the database schema for <' . $app . '> can be updated (this can take a long time depending on the database size)', ['app' => 'updater']);
597
+        });
598
+        $this->listen('\OC\Updater', 'appUpgradeCheck', function () use ($log) {
599
+            $log->info('\OC\Updater::appUpgradeCheck: Checked database schema update for apps', ['app' => 'updater']);
600
+        });
601
+        $this->listen('\OC\Updater', 'appUpgradeStarted', function ($app) use ($log) {
602
+            $log->info('\OC\Updater::appUpgradeStarted: Updating <' . $app . '> ...', ['app' => 'updater']);
603
+        });
604
+        $this->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($log) {
605
+            $log->info('\OC\Updater::appUpgrade: Updated <' . $app . '> to ' . $version, ['app' => 'updater']);
606
+        });
607
+        $this->listen('\OC\Updater', 'failure', function ($message) use($log) {
608
+            $log->error('\OC\Updater::failure: ' . $message, ['app' => 'updater']);
609
+        });
610
+        $this->listen('\OC\Updater', 'setDebugLogLevel', function () use($log) {
611
+            $log->info('\OC\Updater::setDebugLogLevel: Set log level to debug', ['app' => 'updater']);
612
+        });
613
+        $this->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($log) {
614
+            $log->info('\OC\Updater::resetLogLevel: Reset log level to ' . $logLevelName . '(' . $logLevel . ')', ['app' => 'updater']);
615
+        });
616
+        $this->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use($log) {
617
+            $log->info('\OC\Updater::startCheckCodeIntegrity: Starting code integrity check...', ['app' => 'updater']);
618
+        });
619
+        $this->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use($log) {
620
+            $log->info('\OC\Updater::finishedCheckCodeIntegrity: Finished code integrity check', ['app' => 'updater']);
621
+        });
622
+
623
+    }
624 624
 
625 625
 }
626 626
 
Please login to merge, or discard this patch.
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
 		// If at least PHP 7.0.0 is used we don't need to disable apps as we catch
87 87
 		// fatal errors and exceptions and disable the app just instead.
88
-		if(version_compare(phpversion(), '7.0.0', '>=')) {
88
+		if (version_compare(phpversion(), '7.0.0', '>=')) {
89 89
 			$this->skip3rdPartyAppsDisable = true;
90 90
 		}
91 91
 	}
@@ -111,43 +111,43 @@  discard block
 block discarded – undo
111 111
 		$this->logAllEvents();
112 112
 
113 113
 		$logLevel = $this->config->getSystemValue('loglevel', Util::WARN);
114
-		$this->emit('\OC\Updater', 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]);
114
+		$this->emit('\OC\Updater', 'setDebugLogLevel', [$logLevel, $this->logLevelNames[$logLevel]]);
115 115
 		$this->config->setSystemValue('loglevel', Util::DEBUG);
116 116
 
117 117
 		$wasMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false);
118 118
 
119
-		if(!$wasMaintenanceModeEnabled) {
119
+		if (!$wasMaintenanceModeEnabled) {
120 120
 			$this->config->setSystemValue('maintenance', true);
121 121
 			$this->emit('\OC\Updater', 'maintenanceEnabled');
122 122
 		}
123 123
 
124 124
 		$installedVersion = $this->config->getSystemValue('version', '0.0.0');
125 125
 		$currentVersion = implode('.', \OCP\Util::getVersion());
126
-		$this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core'));
126
+		$this->log->debug('starting upgrade from '.$installedVersion.' to '.$currentVersion, array('app' => 'core'));
127 127
 
128 128
 		$success = true;
129 129
 		try {
130 130
 			$this->doUpgrade($currentVersion, $installedVersion);
131 131
 		} catch (HintException $exception) {
132 132
 			$this->log->logException($exception, ['app' => 'core']);
133
-			$this->emit('\OC\Updater', 'failure', array($exception->getMessage() . ': ' .$exception->getHint()));
133
+			$this->emit('\OC\Updater', 'failure', array($exception->getMessage().': '.$exception->getHint()));
134 134
 			$success = false;
135 135
 		} catch (\Exception $exception) {
136 136
 			$this->log->logException($exception, ['app' => 'core']);
137
-			$this->emit('\OC\Updater', 'failure', array(get_class($exception) . ': ' .$exception->getMessage()));
137
+			$this->emit('\OC\Updater', 'failure', array(get_class($exception).': '.$exception->getMessage()));
138 138
 			$success = false;
139 139
 		}
140 140
 
141 141
 		$this->emit('\OC\Updater', 'updateEnd', array($success));
142 142
 
143
-		if(!$wasMaintenanceModeEnabled && $success) {
143
+		if (!$wasMaintenanceModeEnabled && $success) {
144 144
 			$this->config->setSystemValue('maintenance', false);
145 145
 			$this->emit('\OC\Updater', 'maintenanceDisabled');
146 146
 		} else {
147 147
 			$this->emit('\OC\Updater', 'maintenanceActive');
148 148
 		}
149 149
 
150
-		$this->emit('\OC\Updater', 'resetLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]);
150
+		$this->emit('\OC\Updater', 'resetLogLevel', [$logLevel, $this->logLevelNames[$logLevel]]);
151 151
 		$this->config->setSystemValue('loglevel', $logLevel);
152 152
 		$this->config->setSystemValue('installed', true);
153 153
 
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	 */
162 162
 	private function getAllowedPreviousVersions() {
163 163
 		// this should really be a JSON file
164
-		require \OC::$SERVERROOT . '/version.php';
164
+		require \OC::$SERVERROOT.'/version.php';
165 165
 		/** @var array $OC_VersionCanBeUpgradedFrom */
166 166
 		return $OC_VersionCanBeUpgradedFrom;
167 167
 	}
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 	 */
174 174
 	private function getVendor() {
175 175
 		// this should really be a JSON file
176
-		require \OC::$SERVERROOT . '/version.php';
176
+		require \OC::$SERVERROOT.'/version.php';
177 177
 		/** @var string $vendor */
178 178
 		return (string) $vendor;
179 179
 	}
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	 */
188 188
 	public function isUpgradePossible($oldVersion, $newVersion, array $allowedPreviousVersions) {
189 189
 		$version = explode('.', $oldVersion);
190
-		$majorMinor = $version[0] . '.' . $version[1];
190
+		$majorMinor = $version[0].'.'.$version[1];
191 191
 
192 192
 		$currentVendor = $this->config->getAppValue('core', 'vendor', '');
193 193
 		if ($currentVendor === 'nextcloud') {
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 		// create empty file in data dir, so we can later find
228 228
 		// out that this is indeed an ownCloud data directory
229 229
 		// (in case it didn't exist before)
230
-		file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
230
+		file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data').'/.ocdata', '');
231 231
 
232 232
 		// pre-upgrade repairs
233 233
 		$repair = new Repair(Repair::getBeforeUpgradeRepairSteps(), \OC::$server->getEventDispatcher());
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 		foreach ($errors as $appId => $exception) {
259 259
 			/** @var \Exception $exception */
260 260
 			$this->log->logException($exception, ['app' => $appId]);
261
-			$this->emit('\OC\Updater', 'failure', [$appId . ': ' . $exception->getMessage()]);
261
+			$this->emit('\OC\Updater', 'failure', [$appId.': '.$exception->getMessage()]);
262 262
 		}
263 263
 
264 264
 		// post-upgrade repairs
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 		$this->config->setAppValue('core', 'lastupdatedat', 0);
270 270
 
271 271
 		// Check for code integrity if not disabled
272
-		if(\OC::$server->getIntegrityCodeChecker()->isCodeCheckEnforced()) {
272
+		if (\OC::$server->getIntegrityCodeChecker()->isCodeCheckEnforced()) {
273 273
 			$this->emit('\OC\Updater', 'startCheckCodeIntegrity');
274 274
 			$this->checker->runInstanceVerification();
275 275
 			$this->emit('\OC\Updater', 'finishedCheckCodeIntegrity');
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 		$this->emit('\OC\Updater', 'dbUpgradeBefore');
285 285
 
286 286
 		// do the real upgrade
287
-		\OC_DB::updateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml');
287
+		\OC_DB::updateDbFromStructure(\OC::$SERVERROOT.'/db_structure.xml');
288 288
 
289 289
 		$this->emit('\OC\Updater', 'dbUpgrade');
290 290
 	}
@@ -308,12 +308,12 @@  discard block
 block discarded – undo
308 308
 				 * @link https://github.com/owncloud/core/issues/10980
309 309
 				 * @see \OC_App::updateApp
310 310
 				 */
311
-				if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/preupdate.php')) {
311
+				if (file_exists(\OC_App::getAppPath($appId).'/appinfo/preupdate.php')) {
312 312
 					$this->includePreUpdate($appId);
313 313
 				}
314
-				if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/database.xml')) {
314
+				if (file_exists(\OC_App::getAppPath($appId).'/appinfo/database.xml')) {
315 315
 					$this->emit('\OC\Updater', 'appSimulateUpdate', array($appId));
316
-					\OC_DB::simulateUpdateDbFromStructure(\OC_App::getAppPath($appId) . '/appinfo/database.xml');
316
+					\OC_DB::simulateUpdateDbFromStructure(\OC_App::getAppPath($appId).'/appinfo/database.xml');
317 317
 				}
318 318
 			}
319 319
 		}
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 	 * @param string $appId
327 327
 	 */
328 328
 	private function includePreUpdate($appId) {
329
-		include \OC_App::getAppPath($appId) . '/appinfo/preupdate.php';
329
+		include \OC_App::getAppPath($appId).'/appinfo/preupdate.php';
330 330
 	}
331 331
 
332 332
 	/**
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 		foreach ($apps as $appId) {
345 345
 			$priorityType = false;
346 346
 			foreach ($priorityTypes as $type) {
347
-				if(!isset($stacks[$type])) {
347
+				if (!isset($stacks[$type])) {
348 348
 					$stacks[$type] = array();
349 349
 				}
350 350
 				if (\OC_App::isType($appId, $type)) {
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 					\OC_App::updateApp($appId);
365 365
 					$this->emit('\OC\Updater', 'appUpgrade', [$appId, \OC_App::getAppVersion($appId)]);
366 366
 				}
367
-				if($type !== $pseudoOtherType) {
367
+				if ($type !== $pseudoOtherType) {
368 368
 					// load authentication, filesystem and logging apps after
369 369
 					// upgrading them. Other apps my need to rely on modifying
370 370
 					// user and/or filesystem aspects.
@@ -391,9 +391,9 @@  discard block
 block discarded – undo
391 391
 		foreach ($apps as $app) {
392 392
 			// check if the app is compatible with this version of ownCloud
393 393
 			$info = OC_App::getAppInfo($app);
394
-			if(!OC_App::isAppCompatible($version, $info)) {
394
+			if (!OC_App::isAppCompatible($version, $info)) {
395 395
 				if (OC_App::isShipped($app)) {
396
-					throw new \UnexpectedValueException('The files of the app "' . $app . '" were not correctly replaced before running the update');
396
+					throw new \UnexpectedValueException('The files of the app "'.$app.'" were not correctly replaced before running the update');
397 397
 				}
398 398
 				OC_App::disable($app);
399 399
 				$this->emit('\OC\Updater', 'incompatibleAppDisabled', array($app));
@@ -412,9 +412,9 @@  discard block
 block discarded – undo
412 412
 			}
413 413
 
414 414
 			// disable any other 3rd party apps if not overriden
415
-			if(!$this->skip3rdPartyAppsDisable) {
415
+			if (!$this->skip3rdPartyAppsDisable) {
416 416
 				\OC_App::disable($app);
417
-				$disabledApps[]= $app;
417
+				$disabledApps[] = $app;
418 418
 				$this->emit('\OC\Updater', 'thirdPartyAppDisabled', array($app));
419 419
 			};
420 420
 		}
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 	 * @throws \Exception
439 439
 	 */
440 440
 	private function upgradeAppStoreApps(array $disabledApps) {
441
-		foreach($disabledApps as $app) {
441
+		foreach ($disabledApps as $app) {
442 442
 			try {
443 443
 				$installer = new Installer(
444 444
 					\OC::$server->getAppFetcher(),
@@ -464,22 +464,22 @@  discard block
 block discarded – undo
464 464
 	 */
465 465
 	private function emitRepairEvents() {
466 466
 		$dispatcher = \OC::$server->getEventDispatcher();
467
-		$dispatcher->addListener('\OC\Repair::warning', function ($event) {
467
+		$dispatcher->addListener('\OC\Repair::warning', function($event) {
468 468
 			if ($event instanceof GenericEvent) {
469 469
 				$this->emit('\OC\Updater', 'repairWarning', $event->getArguments());
470 470
 			}
471 471
 		});
472
-		$dispatcher->addListener('\OC\Repair::error', function ($event) {
472
+		$dispatcher->addListener('\OC\Repair::error', function($event) {
473 473
 			if ($event instanceof GenericEvent) {
474 474
 				$this->emit('\OC\Updater', 'repairError', $event->getArguments());
475 475
 			}
476 476
 		});
477
-		$dispatcher->addListener('\OC\Repair::info', function ($event) {
477
+		$dispatcher->addListener('\OC\Repair::info', function($event) {
478 478
 			if ($event instanceof GenericEvent) {
479 479
 				$this->emit('\OC\Updater', 'repairInfo', $event->getArguments());
480 480
 			}
481 481
 		});
482
-		$dispatcher->addListener('\OC\Repair::step', function ($event) {
482
+		$dispatcher->addListener('\OC\Repair::step', function($event) {
483 483
 			if ($event instanceof GenericEvent) {
484 484
 				$this->emit('\OC\Updater', 'repairStep', $event->getArguments());
485 485
 			}
@@ -494,13 +494,13 @@  discard block
 block discarded – undo
494 494
 			if (!$event instanceof GenericEvent) {
495 495
 				return;
496 496
 			}
497
-			$log->info('\OC\DB\Migrator::executeSql: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']);
497
+			$log->info('\OC\DB\Migrator::executeSql: '.$event->getSubject().' ('.$event->getArgument(0).' of '.$event->getArgument(1).')', ['app' => 'updater']);
498 498
 		});
499 499
 		$dispatcher->addListener('\OC\DB\Migrator::checkTable', function($event) use ($log) {
500 500
 			if (!$event instanceof GenericEvent) {
501 501
 				return;
502 502
 			}
503
-			$log->info('\OC\DB\Migrator::checkTable: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']);
503
+			$log->info('\OC\DB\Migrator::checkTable: '.$event->getSubject().' ('.$event->getArgument(0).' of '.$event->getArgument(1).')', ['app' => 'updater']);
504 504
 		});
505 505
 
506 506
 		$repairListener = function($event) use ($log) {
@@ -509,30 +509,30 @@  discard block
 block discarded – undo
509 509
 			}
510 510
 			switch ($event->getSubject()) {
511 511
 				case '\OC\Repair::startProgress':
512
-					$log->info('\OC\Repair::startProgress: Starting ... ' . $event->getArgument(1) .  ' (' . $event->getArgument(0) . ')', ['app' => 'updater']);
512
+					$log->info('\OC\Repair::startProgress: Starting ... '.$event->getArgument(1).' ('.$event->getArgument(0).')', ['app' => 'updater']);
513 513
 					break;
514 514
 				case '\OC\Repair::advance':
515 515
 					$desc = $event->getArgument(1);
516 516
 					if (empty($desc)) {
517 517
 						$desc = '';
518 518
 					}
519
-					$log->info('\OC\Repair::advance: ' . $desc . ' (' . $event->getArgument(0) . ')', ['app' => 'updater']);
519
+					$log->info('\OC\Repair::advance: '.$desc.' ('.$event->getArgument(0).')', ['app' => 'updater']);
520 520
 
521 521
 					break;
522 522
 				case '\OC\Repair::finishProgress':
523 523
 					$log->info('\OC\Repair::finishProgress', ['app' => 'updater']);
524 524
 					break;
525 525
 				case '\OC\Repair::step':
526
-					$log->info('\OC\Repair::step: Repair step: ' . $event->getArgument(0), ['app' => 'updater']);
526
+					$log->info('\OC\Repair::step: Repair step: '.$event->getArgument(0), ['app' => 'updater']);
527 527
 					break;
528 528
 				case '\OC\Repair::info':
529
-					$log->info('\OC\Repair::info: Repair info: ' . $event->getArgument(0), ['app' => 'updater']);
529
+					$log->info('\OC\Repair::info: Repair info: '.$event->getArgument(0), ['app' => 'updater']);
530 530
 					break;
531 531
 				case '\OC\Repair::warning':
532
-					$log->warning('\OC\Repair::warning: Repair warning: ' . $event->getArgument(0), ['app' => 'updater']);
532
+					$log->warning('\OC\Repair::warning: Repair warning: '.$event->getArgument(0), ['app' => 'updater']);
533 533
 					break;
534 534
 				case '\OC\Repair::error':
535
-					$log->error('\OC\Repair::error: Repair error: ' . $event->getArgument(0), ['app' => 'updater']);
535
+					$log->error('\OC\Repair::error: Repair error: '.$event->getArgument(0), ['app' => 'updater']);
536 536
 					break;
537 537
 			}
538 538
 		};
@@ -546,77 +546,77 @@  discard block
 block discarded – undo
546 546
 		$dispatcher->addListener('\OC\Repair::error', $repairListener);
547 547
 
548 548
 
549
-		$this->listen('\OC\Updater', 'maintenanceEnabled', function () use($log) {
549
+		$this->listen('\OC\Updater', 'maintenanceEnabled', function() use($log) {
550 550
 			$log->info('\OC\Updater::maintenanceEnabled: Turned on maintenance mode', ['app' => 'updater']);
551 551
 		});
552
-		$this->listen('\OC\Updater', 'maintenanceDisabled', function () use($log) {
552
+		$this->listen('\OC\Updater', 'maintenanceDisabled', function() use($log) {
553 553
 			$log->info('\OC\Updater::maintenanceDisabled: Turned off maintenance mode', ['app' => 'updater']);
554 554
 		});
555
-		$this->listen('\OC\Updater', 'maintenanceActive', function () use($log) {
555
+		$this->listen('\OC\Updater', 'maintenanceActive', function() use($log) {
556 556
 			$log->info('\OC\Updater::maintenanceActive: Maintenance mode is kept active', ['app' => 'updater']);
557 557
 		});
558
-		$this->listen('\OC\Updater', 'updateEnd', function ($success) use($log) {
558
+		$this->listen('\OC\Updater', 'updateEnd', function($success) use($log) {
559 559
 			if ($success) {
560 560
 				$log->info('\OC\Updater::updateEnd: Update successful', ['app' => 'updater']);
561 561
 			} else {
562 562
 				$log->error('\OC\Updater::updateEnd: Update failed', ['app' => 'updater']);
563 563
 			}
564 564
 		});
565
-		$this->listen('\OC\Updater', 'dbUpgradeBefore', function () use($log) {
565
+		$this->listen('\OC\Updater', 'dbUpgradeBefore', function() use($log) {
566 566
 			$log->info('\OC\Updater::dbUpgradeBefore: Updating database schema', ['app' => 'updater']);
567 567
 		});
568
-		$this->listen('\OC\Updater', 'dbUpgrade', function () use($log) {
568
+		$this->listen('\OC\Updater', 'dbUpgrade', function() use($log) {
569 569
 			$log->info('\OC\Updater::dbUpgrade: Updated database', ['app' => 'updater']);
570 570
 		});
571
-		$this->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($log) {
571
+		$this->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function() use($log) {
572 572
 			$log->info('\OC\Updater::dbSimulateUpgradeBefore: Checking whether the database schema can be updated (this can take a long time depending on the database size)', ['app' => 'updater']);
573 573
 		});
574
-		$this->listen('\OC\Updater', 'dbSimulateUpgrade', function () use($log) {
574
+		$this->listen('\OC\Updater', 'dbSimulateUpgrade', function() use($log) {
575 575
 			$log->info('\OC\Updater::dbSimulateUpgrade: Checked database schema update', ['app' => 'updater']);
576 576
 		});
577
-		$this->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use($log) {
578
-			$log->info('\OC\Updater::incompatibleAppDisabled: Disabled incompatible app: ' . $app, ['app' => 'updater']);
577
+		$this->listen('\OC\Updater', 'incompatibleAppDisabled', function($app) use($log) {
578
+			$log->info('\OC\Updater::incompatibleAppDisabled: Disabled incompatible app: '.$app, ['app' => 'updater']);
579 579
 		});
580
-		$this->listen('\OC\Updater', 'thirdPartyAppDisabled', function ($app) use ($log) {
581
-			$log->info('\OC\Updater::thirdPartyAppDisabled: Disabled 3rd-party app: ' . $app, ['app' => 'updater']);
580
+		$this->listen('\OC\Updater', 'thirdPartyAppDisabled', function($app) use ($log) {
581
+			$log->info('\OC\Updater::thirdPartyAppDisabled: Disabled 3rd-party app: '.$app, ['app' => 'updater']);
582 582
 		});
583
-		$this->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use($log) {
584
-			$log->info('\OC\Updater::checkAppStoreAppBefore: Checking for update of app "' . $app . '" in appstore', ['app' => 'updater']);
583
+		$this->listen('\OC\Updater', 'checkAppStoreAppBefore', function($app) use($log) {
584
+			$log->info('\OC\Updater::checkAppStoreAppBefore: Checking for update of app "'.$app.'" in appstore', ['app' => 'updater']);
585 585
 		});
586
-		$this->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use($log) {
587
-			$log->info('\OC\Updater::upgradeAppStoreApp: Update app "' . $app . '" from appstore', ['app' => 'updater']);
586
+		$this->listen('\OC\Updater', 'upgradeAppStoreApp', function($app) use($log) {
587
+			$log->info('\OC\Updater::upgradeAppStoreApp: Update app "'.$app.'" from appstore', ['app' => 'updater']);
588 588
 		});
589
-		$this->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use($log) {
590
-			$log->info('\OC\Updater::checkAppStoreApp: Checked for update of app "' . $app . '" in appstore', ['app' => 'updater']);
589
+		$this->listen('\OC\Updater', 'checkAppStoreApp', function($app) use($log) {
590
+			$log->info('\OC\Updater::checkAppStoreApp: Checked for update of app "'.$app.'" in appstore', ['app' => 'updater']);
591 591
 		});
592
-		$this->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($log) {
592
+		$this->listen('\OC\Updater', 'appUpgradeCheckBefore', function() use ($log) {
593 593
 			$log->info('\OC\Updater::appUpgradeCheckBefore: Checking updates of apps', ['app' => 'updater']);
594 594
 		});
595
-		$this->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($log) {
596
-			$log->info('\OC\Updater::appSimulateUpdate: Checking whether the database schema for <' . $app . '> can be updated (this can take a long time depending on the database size)', ['app' => 'updater']);
595
+		$this->listen('\OC\Updater', 'appSimulateUpdate', function($app) use ($log) {
596
+			$log->info('\OC\Updater::appSimulateUpdate: Checking whether the database schema for <'.$app.'> can be updated (this can take a long time depending on the database size)', ['app' => 'updater']);
597 597
 		});
598
-		$this->listen('\OC\Updater', 'appUpgradeCheck', function () use ($log) {
598
+		$this->listen('\OC\Updater', 'appUpgradeCheck', function() use ($log) {
599 599
 			$log->info('\OC\Updater::appUpgradeCheck: Checked database schema update for apps', ['app' => 'updater']);
600 600
 		});
601
-		$this->listen('\OC\Updater', 'appUpgradeStarted', function ($app) use ($log) {
602
-			$log->info('\OC\Updater::appUpgradeStarted: Updating <' . $app . '> ...', ['app' => 'updater']);
601
+		$this->listen('\OC\Updater', 'appUpgradeStarted', function($app) use ($log) {
602
+			$log->info('\OC\Updater::appUpgradeStarted: Updating <'.$app.'> ...', ['app' => 'updater']);
603 603
 		});
604
-		$this->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($log) {
605
-			$log->info('\OC\Updater::appUpgrade: Updated <' . $app . '> to ' . $version, ['app' => 'updater']);
604
+		$this->listen('\OC\Updater', 'appUpgrade', function($app, $version) use ($log) {
605
+			$log->info('\OC\Updater::appUpgrade: Updated <'.$app.'> to '.$version, ['app' => 'updater']);
606 606
 		});
607
-		$this->listen('\OC\Updater', 'failure', function ($message) use($log) {
608
-			$log->error('\OC\Updater::failure: ' . $message, ['app' => 'updater']);
607
+		$this->listen('\OC\Updater', 'failure', function($message) use($log) {
608
+			$log->error('\OC\Updater::failure: '.$message, ['app' => 'updater']);
609 609
 		});
610
-		$this->listen('\OC\Updater', 'setDebugLogLevel', function () use($log) {
610
+		$this->listen('\OC\Updater', 'setDebugLogLevel', function() use($log) {
611 611
 			$log->info('\OC\Updater::setDebugLogLevel: Set log level to debug', ['app' => 'updater']);
612 612
 		});
613
-		$this->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($log) {
614
-			$log->info('\OC\Updater::resetLogLevel: Reset log level to ' . $logLevelName . '(' . $logLevel . ')', ['app' => 'updater']);
613
+		$this->listen('\OC\Updater', 'resetLogLevel', function($logLevel, $logLevelName) use($log) {
614
+			$log->info('\OC\Updater::resetLogLevel: Reset log level to '.$logLevelName.'('.$logLevel.')', ['app' => 'updater']);
615 615
 		});
616
-		$this->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use($log) {
616
+		$this->listen('\OC\Updater', 'startCheckCodeIntegrity', function() use($log) {
617 617
 			$log->info('\OC\Updater::startCheckCodeIntegrity: Starting code integrity check...', ['app' => 'updater']);
618 618
 		});
619
-		$this->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use($log) {
619
+		$this->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function() use($log) {
620 620
 			$log->info('\OC\Updater::finishedCheckCodeIntegrity: Finished code integrity check', ['app' => 'updater']);
621 621
 		});
622 622
 
Please login to merge, or discard this patch.
core/ajax/update.php 2 patches
Indentation   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 use Symfony\Component\EventDispatcher\GenericEvent;
31 31
 
32 32
 if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
33
-	@set_time_limit(0);
33
+    @set_time_limit(0);
34 34
 }
35 35
 
36 36
 require_once '../../lib/base.php';
@@ -44,186 +44,186 @@  discard block
 block discarded – undo
44 44
 $eventSource->send('success', (string)$l->t('Preparing update'));
45 45
 
46 46
 class FeedBackHandler {
47
-	/** @var integer */
48
-	private $progressStateMax = 100;
49
-	/** @var integer */
50
-	private $progressStateStep = 0;
51
-	/** @var string */
52
-	private $currentStep;
53
-
54
-	public function __construct(\OCP\IEventSource $eventSource, \OCP\IL10N $l10n) {
55
-		$this->eventSource = $eventSource;
56
-		$this->l10n = $l10n;
57
-	}
58
-
59
-	public function handleRepairFeedback($event) {
60
-		if (!$event instanceof GenericEvent) {
61
-			return;
62
-		}
63
-
64
-		switch ($event->getSubject()) {
65
-			case '\OC\Repair::startProgress':
66
-				$this->progressStateMax = $event->getArgument(0);
67
-				$this->progressStateStep = 0;
68
-				$this->currentStep = $event->getArgument(1);
69
-				break;
70
-			case '\OC\Repair::advance':
71
-				$this->progressStateStep += $event->getArgument(0);
72
-				$desc = $event->getArgument(1);
73
-				if (empty($desc)) {
74
-					$desc = $this->currentStep;
75
-				}
76
-				$this->eventSource->send('success', (string)$this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $desc]));
77
-				break;
78
-			case '\OC\Repair::finishProgress':
79
-				$this->progressStateMax = $this->progressStateStep;
80
-				$this->eventSource->send('success', (string)$this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $this->currentStep]));
81
-				break;
82
-			case '\OC\Repair::step':
83
-				break;
84
-			case '\OC\Repair::info':
85
-				break;
86
-			case '\OC\Repair::warning':
87
-				$this->eventSource->send('notice', (string)$this->l10n->t('Repair warning: ') . $event->getArgument(0));
88
-				break;
89
-			case '\OC\Repair::error':
90
-				$this->eventSource->send('notice', (string)$this->l10n->t('Repair error: ') . $event->getArgument(0));
91
-				break;
92
-		}
93
-	}
47
+    /** @var integer */
48
+    private $progressStateMax = 100;
49
+    /** @var integer */
50
+    private $progressStateStep = 0;
51
+    /** @var string */
52
+    private $currentStep;
53
+
54
+    public function __construct(\OCP\IEventSource $eventSource, \OCP\IL10N $l10n) {
55
+        $this->eventSource = $eventSource;
56
+        $this->l10n = $l10n;
57
+    }
58
+
59
+    public function handleRepairFeedback($event) {
60
+        if (!$event instanceof GenericEvent) {
61
+            return;
62
+        }
63
+
64
+        switch ($event->getSubject()) {
65
+            case '\OC\Repair::startProgress':
66
+                $this->progressStateMax = $event->getArgument(0);
67
+                $this->progressStateStep = 0;
68
+                $this->currentStep = $event->getArgument(1);
69
+                break;
70
+            case '\OC\Repair::advance':
71
+                $this->progressStateStep += $event->getArgument(0);
72
+                $desc = $event->getArgument(1);
73
+                if (empty($desc)) {
74
+                    $desc = $this->currentStep;
75
+                }
76
+                $this->eventSource->send('success', (string)$this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $desc]));
77
+                break;
78
+            case '\OC\Repair::finishProgress':
79
+                $this->progressStateMax = $this->progressStateStep;
80
+                $this->eventSource->send('success', (string)$this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $this->currentStep]));
81
+                break;
82
+            case '\OC\Repair::step':
83
+                break;
84
+            case '\OC\Repair::info':
85
+                break;
86
+            case '\OC\Repair::warning':
87
+                $this->eventSource->send('notice', (string)$this->l10n->t('Repair warning: ') . $event->getArgument(0));
88
+                break;
89
+            case '\OC\Repair::error':
90
+                $this->eventSource->send('notice', (string)$this->l10n->t('Repair error: ') . $event->getArgument(0));
91
+                break;
92
+        }
93
+    }
94 94
 }
95 95
 
96 96
 if (OC::checkUpgrade(false)) {
97 97
 
98
-	$config = \OC::$server->getSystemConfig();
99
-	if ($config->getValue('upgrade.disable-web', false)) {
100
-		$eventSource->send('failure', (string)$l->t('Please use the command line updater because automatic updating is disabled in the config.php.'));
101
-		$eventSource->close();
102
-		exit();
103
-	}
104
-
105
-	// if a user is currently logged in, their session must be ignored to
106
-	// avoid side effects
107
-	\OC_User::setIncognitoMode(true);
108
-
109
-	$logger = \OC::$server->getLogger();
110
-	$config = \OC::$server->getConfig();
111
-	$updater = new \OC\Updater(
112
-			$config,
113
-			\OC::$server->getIntegrityCodeChecker(),
114
-			$logger
115
-	);
116
-	$incompatibleApps = [];
117
-	$disabledThirdPartyApps = [];
118
-
119
-	$dispatcher = \OC::$server->getEventDispatcher();
120
-	$dispatcher->addListener('\OC\DB\Migrator::executeSql', function($event) use ($eventSource, $l) {
121
-		if ($event instanceof GenericEvent) {
122
-			$eventSource->send('success', (string)$l->t('[%d / %d]: %s', [$event[0], $event[1], $event->getSubject()]));
123
-		}
124
-	});
125
-	$dispatcher->addListener('\OC\DB\Migrator::checkTable', function($event) use ($eventSource, $l) {
126
-		if ($event instanceof GenericEvent) {
127
-			$eventSource->send('success', (string)$l->t('[%d / %d]: Checking table %s', [$event[0], $event[1], $event->getSubject()]));
128
-		}
129
-	});
130
-	$feedBack = new FeedBackHandler($eventSource, $l);
131
-	$dispatcher->addListener('\OC\Repair::startProgress', [$feedBack, 'handleRepairFeedback']);
132
-	$dispatcher->addListener('\OC\Repair::advance', [$feedBack, 'handleRepairFeedback']);
133
-	$dispatcher->addListener('\OC\Repair::finishProgress', [$feedBack, 'handleRepairFeedback']);
134
-	$dispatcher->addListener('\OC\Repair::step', [$feedBack, 'handleRepairFeedback']);
135
-	$dispatcher->addListener('\OC\Repair::info', [$feedBack, 'handleRepairFeedback']);
136
-	$dispatcher->addListener('\OC\Repair::warning', [$feedBack, 'handleRepairFeedback']);
137
-	$dispatcher->addListener('\OC\Repair::error', [$feedBack, 'handleRepairFeedback']);
138
-
139
-	$updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($eventSource, $l) {
140
-		$eventSource->send('success', (string)$l->t('Turned on maintenance mode'));
141
-	});
142
-	$updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($eventSource, $l) {
143
-		$eventSource->send('success', (string)$l->t('Turned off maintenance mode'));
144
-	});
145
-	$updater->listen('\OC\Updater', 'maintenanceActive', function () use ($eventSource, $l) {
146
-		$eventSource->send('success', (string)$l->t('Maintenance mode is kept active'));
147
-	});
148
-	$updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use($eventSource, $l) {
149
-		$eventSource->send('success', (string)$l->t('Updating database schema'));
150
-	});
151
-	$updater->listen('\OC\Updater', 'dbUpgrade', function () use ($eventSource, $l) {
152
-		$eventSource->send('success', (string)$l->t('Updated database'));
153
-	});
154
-	$updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($eventSource, $l) {
155
-		$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)'));
156
-	});
157
-	$updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($eventSource, $l) {
158
-		$eventSource->send('success', (string)$l->t('Checked database schema update'));
159
-	});
160
-	$updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($eventSource, $l) {
161
-		$eventSource->send('success', (string)$l->t('Checking updates of apps'));
162
-	});
163
-	$updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($eventSource, $l) {
164
-		$eventSource->send('success', (string)$l->t('Checking for update of app "%s" in appstore', [$app]));
165
-	});
166
-	$updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($eventSource, $l) {
167
-		$eventSource->send('success', (string)$l->t('Update app "%s" from appstore', [$app]));
168
-	});
169
-	$updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($eventSource, $l) {
170
-		$eventSource->send('success', (string)$l->t('Checked for update of app "%s" in appstore', [$app]));
171
-	});
172
-	$updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($eventSource, $l) {
173
-		$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]));
174
-	});
175
-	$updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($eventSource, $l) {
176
-		$eventSource->send('success', (string)$l->t('Checked database schema update for apps'));
177
-	});
178
-	$updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($eventSource, $l) {
179
-		$eventSource->send('success', (string)$l->t('Updated "%s" to %s', array($app, $version)));
180
-	});
181
-	$updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use (&$incompatibleApps) {
182
-		$incompatibleApps[]= $app;
183
-	});
184
-	$updater->listen('\OC\Updater', 'thirdPartyAppDisabled', function ($app) use (&$disabledThirdPartyApps) {
185
-		$disabledThirdPartyApps[]= $app;
186
-	});
187
-	$updater->listen('\OC\Updater', 'failure', function ($message) use ($eventSource, $config) {
188
-		$eventSource->send('failure', $message);
189
-		$eventSource->close();
190
-		$config->setSystemValue('maintenance', false);
191
-	});
192
-	$updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use($eventSource, $l) {
193
-		$eventSource->send('success', (string)$l->t('Set log level to debug'));
194
-	});
195
-	$updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($eventSource, $l) {
196
-		$eventSource->send('success', (string)$l->t('Reset log level'));
197
-	});
198
-	$updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use($eventSource, $l) {
199
-		$eventSource->send('success', (string)$l->t('Starting code integrity check'));
200
-	});
201
-	$updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use($eventSource, $l) {
202
-		$eventSource->send('success', (string)$l->t('Finished code integrity check'));
203
-	});
204
-
205
-	try {
206
-		$updater->upgrade();
207
-	} catch (\Exception $e) {
208
-		$eventSource->send('failure', get_class($e) . ': ' . $e->getMessage());
209
-		$eventSource->close();
210
-		exit();
211
-	}
212
-
213
-	$disabledApps = [];
214
-	foreach ($disabledThirdPartyApps as $app) {
215
-		$disabledApps[$app] = (string) $l->t('%s (3rdparty)', [$app]);
216
-	}
217
-	foreach ($incompatibleApps as $app) {
218
-		$disabledApps[$app] = (string) $l->t('%s (incompatible)', [$app]);
219
-	}
220
-
221
-	if (!empty($disabledApps)) {
222
-		$eventSource->send('notice',
223
-			(string)$l->t('Following apps have been disabled: %s', implode(', ', $disabledApps)));
224
-	}
98
+    $config = \OC::$server->getSystemConfig();
99
+    if ($config->getValue('upgrade.disable-web', false)) {
100
+        $eventSource->send('failure', (string)$l->t('Please use the command line updater because automatic updating is disabled in the config.php.'));
101
+        $eventSource->close();
102
+        exit();
103
+    }
104
+
105
+    // if a user is currently logged in, their session must be ignored to
106
+    // avoid side effects
107
+    \OC_User::setIncognitoMode(true);
108
+
109
+    $logger = \OC::$server->getLogger();
110
+    $config = \OC::$server->getConfig();
111
+    $updater = new \OC\Updater(
112
+            $config,
113
+            \OC::$server->getIntegrityCodeChecker(),
114
+            $logger
115
+    );
116
+    $incompatibleApps = [];
117
+    $disabledThirdPartyApps = [];
118
+
119
+    $dispatcher = \OC::$server->getEventDispatcher();
120
+    $dispatcher->addListener('\OC\DB\Migrator::executeSql', function($event) use ($eventSource, $l) {
121
+        if ($event instanceof GenericEvent) {
122
+            $eventSource->send('success', (string)$l->t('[%d / %d]: %s', [$event[0], $event[1], $event->getSubject()]));
123
+        }
124
+    });
125
+    $dispatcher->addListener('\OC\DB\Migrator::checkTable', function($event) use ($eventSource, $l) {
126
+        if ($event instanceof GenericEvent) {
127
+            $eventSource->send('success', (string)$l->t('[%d / %d]: Checking table %s', [$event[0], $event[1], $event->getSubject()]));
128
+        }
129
+    });
130
+    $feedBack = new FeedBackHandler($eventSource, $l);
131
+    $dispatcher->addListener('\OC\Repair::startProgress', [$feedBack, 'handleRepairFeedback']);
132
+    $dispatcher->addListener('\OC\Repair::advance', [$feedBack, 'handleRepairFeedback']);
133
+    $dispatcher->addListener('\OC\Repair::finishProgress', [$feedBack, 'handleRepairFeedback']);
134
+    $dispatcher->addListener('\OC\Repair::step', [$feedBack, 'handleRepairFeedback']);
135
+    $dispatcher->addListener('\OC\Repair::info', [$feedBack, 'handleRepairFeedback']);
136
+    $dispatcher->addListener('\OC\Repair::warning', [$feedBack, 'handleRepairFeedback']);
137
+    $dispatcher->addListener('\OC\Repair::error', [$feedBack, 'handleRepairFeedback']);
138
+
139
+    $updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($eventSource, $l) {
140
+        $eventSource->send('success', (string)$l->t('Turned on maintenance mode'));
141
+    });
142
+    $updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($eventSource, $l) {
143
+        $eventSource->send('success', (string)$l->t('Turned off maintenance mode'));
144
+    });
145
+    $updater->listen('\OC\Updater', 'maintenanceActive', function () use ($eventSource, $l) {
146
+        $eventSource->send('success', (string)$l->t('Maintenance mode is kept active'));
147
+    });
148
+    $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use($eventSource, $l) {
149
+        $eventSource->send('success', (string)$l->t('Updating database schema'));
150
+    });
151
+    $updater->listen('\OC\Updater', 'dbUpgrade', function () use ($eventSource, $l) {
152
+        $eventSource->send('success', (string)$l->t('Updated database'));
153
+    });
154
+    $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($eventSource, $l) {
155
+        $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)'));
156
+    });
157
+    $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($eventSource, $l) {
158
+        $eventSource->send('success', (string)$l->t('Checked database schema update'));
159
+    });
160
+    $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($eventSource, $l) {
161
+        $eventSource->send('success', (string)$l->t('Checking updates of apps'));
162
+    });
163
+    $updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($eventSource, $l) {
164
+        $eventSource->send('success', (string)$l->t('Checking for update of app "%s" in appstore', [$app]));
165
+    });
166
+    $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($eventSource, $l) {
167
+        $eventSource->send('success', (string)$l->t('Update app "%s" from appstore', [$app]));
168
+    });
169
+    $updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($eventSource, $l) {
170
+        $eventSource->send('success', (string)$l->t('Checked for update of app "%s" in appstore', [$app]));
171
+    });
172
+    $updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($eventSource, $l) {
173
+        $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]));
174
+    });
175
+    $updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($eventSource, $l) {
176
+        $eventSource->send('success', (string)$l->t('Checked database schema update for apps'));
177
+    });
178
+    $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($eventSource, $l) {
179
+        $eventSource->send('success', (string)$l->t('Updated "%s" to %s', array($app, $version)));
180
+    });
181
+    $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use (&$incompatibleApps) {
182
+        $incompatibleApps[]= $app;
183
+    });
184
+    $updater->listen('\OC\Updater', 'thirdPartyAppDisabled', function ($app) use (&$disabledThirdPartyApps) {
185
+        $disabledThirdPartyApps[]= $app;
186
+    });
187
+    $updater->listen('\OC\Updater', 'failure', function ($message) use ($eventSource, $config) {
188
+        $eventSource->send('failure', $message);
189
+        $eventSource->close();
190
+        $config->setSystemValue('maintenance', false);
191
+    });
192
+    $updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use($eventSource, $l) {
193
+        $eventSource->send('success', (string)$l->t('Set log level to debug'));
194
+    });
195
+    $updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($eventSource, $l) {
196
+        $eventSource->send('success', (string)$l->t('Reset log level'));
197
+    });
198
+    $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use($eventSource, $l) {
199
+        $eventSource->send('success', (string)$l->t('Starting code integrity check'));
200
+    });
201
+    $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use($eventSource, $l) {
202
+        $eventSource->send('success', (string)$l->t('Finished code integrity check'));
203
+    });
204
+
205
+    try {
206
+        $updater->upgrade();
207
+    } catch (\Exception $e) {
208
+        $eventSource->send('failure', get_class($e) . ': ' . $e->getMessage());
209
+        $eventSource->close();
210
+        exit();
211
+    }
212
+
213
+    $disabledApps = [];
214
+    foreach ($disabledThirdPartyApps as $app) {
215
+        $disabledApps[$app] = (string) $l->t('%s (3rdparty)', [$app]);
216
+    }
217
+    foreach ($incompatibleApps as $app) {
218
+        $disabledApps[$app] = (string) $l->t('%s (incompatible)', [$app]);
219
+    }
220
+
221
+    if (!empty($disabledApps)) {
222
+        $eventSource->send('notice',
223
+            (string)$l->t('Following apps have been disabled: %s', implode(', ', $disabledApps)));
224
+    }
225 225
 } else {
226
-	$eventSource->send('notice', (string)$l->t('Already up to date'));
226
+    $eventSource->send('notice', (string)$l->t('Already up to date'));
227 227
 }
228 228
 
229 229
 $eventSource->send('done', '');
Please login to merge, or discard this patch.
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 // need to send an initial message to force-init the event source,
42 42
 // which will then trigger its own CSRF check and produces its own CSRF error
43 43
 // message
44
-$eventSource->send('success', (string)$l->t('Preparing update'));
44
+$eventSource->send('success', (string) $l->t('Preparing update'));
45 45
 
46 46
 class FeedBackHandler {
47 47
 	/** @var integer */
@@ -73,21 +73,21 @@  discard block
 block discarded – undo
73 73
 				if (empty($desc)) {
74 74
 					$desc = $this->currentStep;
75 75
 				}
76
-				$this->eventSource->send('success', (string)$this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $desc]));
76
+				$this->eventSource->send('success', (string) $this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $desc]));
77 77
 				break;
78 78
 			case '\OC\Repair::finishProgress':
79 79
 				$this->progressStateMax = $this->progressStateStep;
80
-				$this->eventSource->send('success', (string)$this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $this->currentStep]));
80
+				$this->eventSource->send('success', (string) $this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $this->currentStep]));
81 81
 				break;
82 82
 			case '\OC\Repair::step':
83 83
 				break;
84 84
 			case '\OC\Repair::info':
85 85
 				break;
86 86
 			case '\OC\Repair::warning':
87
-				$this->eventSource->send('notice', (string)$this->l10n->t('Repair warning: ') . $event->getArgument(0));
87
+				$this->eventSource->send('notice', (string) $this->l10n->t('Repair warning: ').$event->getArgument(0));
88 88
 				break;
89 89
 			case '\OC\Repair::error':
90
-				$this->eventSource->send('notice', (string)$this->l10n->t('Repair error: ') . $event->getArgument(0));
90
+				$this->eventSource->send('notice', (string) $this->l10n->t('Repair error: ').$event->getArgument(0));
91 91
 				break;
92 92
 		}
93 93
 	}
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 
98 98
 	$config = \OC::$server->getSystemConfig();
99 99
 	if ($config->getValue('upgrade.disable-web', false)) {
100
-		$eventSource->send('failure', (string)$l->t('Please use the command line updater because automatic updating is disabled in the config.php.'));
100
+		$eventSource->send('failure', (string) $l->t('Please use the command line updater because automatic updating is disabled in the config.php.'));
101 101
 		$eventSource->close();
102 102
 		exit();
103 103
 	}
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
 	$dispatcher = \OC::$server->getEventDispatcher();
120 120
 	$dispatcher->addListener('\OC\DB\Migrator::executeSql', function($event) use ($eventSource, $l) {
121 121
 		if ($event instanceof GenericEvent) {
122
-			$eventSource->send('success', (string)$l->t('[%d / %d]: %s', [$event[0], $event[1], $event->getSubject()]));
122
+			$eventSource->send('success', (string) $l->t('[%d / %d]: %s', [$event[0], $event[1], $event->getSubject()]));
123 123
 		}
124 124
 	});
125 125
 	$dispatcher->addListener('\OC\DB\Migrator::checkTable', function($event) use ($eventSource, $l) {
126 126
 		if ($event instanceof GenericEvent) {
127
-			$eventSource->send('success', (string)$l->t('[%d / %d]: Checking table %s', [$event[0], $event[1], $event->getSubject()]));
127
+			$eventSource->send('success', (string) $l->t('[%d / %d]: Checking table %s', [$event[0], $event[1], $event->getSubject()]));
128 128
 		}
129 129
 	});
130 130
 	$feedBack = new FeedBackHandler($eventSource, $l);
@@ -136,76 +136,76 @@  discard block
 block discarded – undo
136 136
 	$dispatcher->addListener('\OC\Repair::warning', [$feedBack, 'handleRepairFeedback']);
137 137
 	$dispatcher->addListener('\OC\Repair::error', [$feedBack, 'handleRepairFeedback']);
138 138
 
139
-	$updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($eventSource, $l) {
140
-		$eventSource->send('success', (string)$l->t('Turned on maintenance mode'));
139
+	$updater->listen('\OC\Updater', 'maintenanceEnabled', function() use ($eventSource, $l) {
140
+		$eventSource->send('success', (string) $l->t('Turned on maintenance mode'));
141 141
 	});
142
-	$updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($eventSource, $l) {
143
-		$eventSource->send('success', (string)$l->t('Turned off maintenance mode'));
142
+	$updater->listen('\OC\Updater', 'maintenanceDisabled', function() use ($eventSource, $l) {
143
+		$eventSource->send('success', (string) $l->t('Turned off maintenance mode'));
144 144
 	});
145
-	$updater->listen('\OC\Updater', 'maintenanceActive', function () use ($eventSource, $l) {
146
-		$eventSource->send('success', (string)$l->t('Maintenance mode is kept active'));
145
+	$updater->listen('\OC\Updater', 'maintenanceActive', function() use ($eventSource, $l) {
146
+		$eventSource->send('success', (string) $l->t('Maintenance mode is kept active'));
147 147
 	});
148
-	$updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use($eventSource, $l) {
149
-		$eventSource->send('success', (string)$l->t('Updating database schema'));
148
+	$updater->listen('\OC\Updater', 'dbUpgradeBefore', function() use($eventSource, $l) {
149
+		$eventSource->send('success', (string) $l->t('Updating database schema'));
150 150
 	});
151
-	$updater->listen('\OC\Updater', 'dbUpgrade', function () use ($eventSource, $l) {
152
-		$eventSource->send('success', (string)$l->t('Updated database'));
151
+	$updater->listen('\OC\Updater', 'dbUpgrade', function() use ($eventSource, $l) {
152
+		$eventSource->send('success', (string) $l->t('Updated database'));
153 153
 	});
154
-	$updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($eventSource, $l) {
155
-		$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)'));
154
+	$updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function() use($eventSource, $l) {
155
+		$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)'));
156 156
 	});
157
-	$updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($eventSource, $l) {
158
-		$eventSource->send('success', (string)$l->t('Checked database schema update'));
157
+	$updater->listen('\OC\Updater', 'dbSimulateUpgrade', function() use ($eventSource, $l) {
158
+		$eventSource->send('success', (string) $l->t('Checked database schema update'));
159 159
 	});
160
-	$updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($eventSource, $l) {
161
-		$eventSource->send('success', (string)$l->t('Checking updates of apps'));
160
+	$updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function() use ($eventSource, $l) {
161
+		$eventSource->send('success', (string) $l->t('Checking updates of apps'));
162 162
 	});
163
-	$updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($eventSource, $l) {
164
-		$eventSource->send('success', (string)$l->t('Checking for update of app "%s" in appstore', [$app]));
163
+	$updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function($app) use ($eventSource, $l) {
164
+		$eventSource->send('success', (string) $l->t('Checking for update of app "%s" in appstore', [$app]));
165 165
 	});
166
-	$updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($eventSource, $l) {
167
-		$eventSource->send('success', (string)$l->t('Update app "%s" from appstore', [$app]));
166
+	$updater->listen('\OC\Updater', 'upgradeAppStoreApp', function($app) use ($eventSource, $l) {
167
+		$eventSource->send('success', (string) $l->t('Update app "%s" from appstore', [$app]));
168 168
 	});
169
-	$updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($eventSource, $l) {
170
-		$eventSource->send('success', (string)$l->t('Checked for update of app "%s" in appstore', [$app]));
169
+	$updater->listen('\OC\Updater', 'checkAppStoreApp', function($app) use ($eventSource, $l) {
170
+		$eventSource->send('success', (string) $l->t('Checked for update of app "%s" in appstore', [$app]));
171 171
 	});
172
-	$updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($eventSource, $l) {
173
-		$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]));
172
+	$updater->listen('\OC\Updater', 'appSimulateUpdate', function($app) use ($eventSource, $l) {
173
+		$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]));
174 174
 	});
175
-	$updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($eventSource, $l) {
176
-		$eventSource->send('success', (string)$l->t('Checked database schema update for apps'));
175
+	$updater->listen('\OC\Updater', 'appUpgradeCheck', function() use ($eventSource, $l) {
176
+		$eventSource->send('success', (string) $l->t('Checked database schema update for apps'));
177 177
 	});
178
-	$updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($eventSource, $l) {
179
-		$eventSource->send('success', (string)$l->t('Updated "%s" to %s', array($app, $version)));
178
+	$updater->listen('\OC\Updater', 'appUpgrade', function($app, $version) use ($eventSource, $l) {
179
+		$eventSource->send('success', (string) $l->t('Updated "%s" to %s', array($app, $version)));
180 180
 	});
181
-	$updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use (&$incompatibleApps) {
182
-		$incompatibleApps[]= $app;
181
+	$updater->listen('\OC\Updater', 'incompatibleAppDisabled', function($app) use (&$incompatibleApps) {
182
+		$incompatibleApps[] = $app;
183 183
 	});
184
-	$updater->listen('\OC\Updater', 'thirdPartyAppDisabled', function ($app) use (&$disabledThirdPartyApps) {
185
-		$disabledThirdPartyApps[]= $app;
184
+	$updater->listen('\OC\Updater', 'thirdPartyAppDisabled', function($app) use (&$disabledThirdPartyApps) {
185
+		$disabledThirdPartyApps[] = $app;
186 186
 	});
187
-	$updater->listen('\OC\Updater', 'failure', function ($message) use ($eventSource, $config) {
187
+	$updater->listen('\OC\Updater', 'failure', function($message) use ($eventSource, $config) {
188 188
 		$eventSource->send('failure', $message);
189 189
 		$eventSource->close();
190 190
 		$config->setSystemValue('maintenance', false);
191 191
 	});
192
-	$updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use($eventSource, $l) {
193
-		$eventSource->send('success', (string)$l->t('Set log level to debug'));
192
+	$updater->listen('\OC\Updater', 'setDebugLogLevel', function($logLevel, $logLevelName) use($eventSource, $l) {
193
+		$eventSource->send('success', (string) $l->t('Set log level to debug'));
194 194
 	});
195
-	$updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($eventSource, $l) {
196
-		$eventSource->send('success', (string)$l->t('Reset log level'));
195
+	$updater->listen('\OC\Updater', 'resetLogLevel', function($logLevel, $logLevelName) use($eventSource, $l) {
196
+		$eventSource->send('success', (string) $l->t('Reset log level'));
197 197
 	});
198
-	$updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use($eventSource, $l) {
199
-		$eventSource->send('success', (string)$l->t('Starting code integrity check'));
198
+	$updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function() use($eventSource, $l) {
199
+		$eventSource->send('success', (string) $l->t('Starting code integrity check'));
200 200
 	});
201
-	$updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use($eventSource, $l) {
202
-		$eventSource->send('success', (string)$l->t('Finished code integrity check'));
201
+	$updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function() use($eventSource, $l) {
202
+		$eventSource->send('success', (string) $l->t('Finished code integrity check'));
203 203
 	});
204 204
 
205 205
 	try {
206 206
 		$updater->upgrade();
207 207
 	} catch (\Exception $e) {
208
-		$eventSource->send('failure', get_class($e) . ': ' . $e->getMessage());
208
+		$eventSource->send('failure', get_class($e).': '.$e->getMessage());
209 209
 		$eventSource->close();
210 210
 		exit();
211 211
 	}
@@ -220,10 +220,10 @@  discard block
 block discarded – undo
220 220
 
221 221
 	if (!empty($disabledApps)) {
222 222
 		$eventSource->send('notice',
223
-			(string)$l->t('Following apps have been disabled: %s', implode(', ', $disabledApps)));
223
+			(string) $l->t('Following apps have been disabled: %s', implode(', ', $disabledApps)));
224 224
 	}
225 225
 } else {
226
-	$eventSource->send('notice', (string)$l->t('Already up to date'));
226
+	$eventSource->send('notice', (string) $l->t('Already up to date'));
227 227
 }
228 228
 
229 229
 $eventSource->send('done', '');
Please login to merge, or discard this patch.
core/Command/Upgrade.php 2 patches
Indentation   +239 added lines, -239 removed lines patch added patch discarded remove patch
@@ -44,260 +44,260 @@
 block discarded – undo
44 44
 
45 45
 class Upgrade extends Command {
46 46
 
47
-	const ERROR_SUCCESS = 0;
48
-	const ERROR_NOT_INSTALLED = 1;
49
-	const ERROR_MAINTENANCE_MODE = 2;
50
-	const ERROR_UP_TO_DATE = 0;
51
-	const ERROR_INVALID_ARGUMENTS = 4;
52
-	const ERROR_FAILURE = 5;
47
+    const ERROR_SUCCESS = 0;
48
+    const ERROR_NOT_INSTALLED = 1;
49
+    const ERROR_MAINTENANCE_MODE = 2;
50
+    const ERROR_UP_TO_DATE = 0;
51
+    const ERROR_INVALID_ARGUMENTS = 4;
52
+    const ERROR_FAILURE = 5;
53 53
 
54
-	/** @var IConfig */
55
-	private $config;
54
+    /** @var IConfig */
55
+    private $config;
56 56
 
57
-	/** @var ILogger */
58
-	private $logger;
57
+    /** @var ILogger */
58
+    private $logger;
59 59
 
60
-	/**
61
-	 * @param IConfig $config
62
-	 * @param ILogger $logger
63
-	 */
64
-	public function __construct(IConfig $config, ILogger $logger) {
65
-		parent::__construct();
66
-		$this->config = $config;
67
-		$this->logger = $logger;
68
-	}
60
+    /**
61
+     * @param IConfig $config
62
+     * @param ILogger $logger
63
+     */
64
+    public function __construct(IConfig $config, ILogger $logger) {
65
+        parent::__construct();
66
+        $this->config = $config;
67
+        $this->logger = $logger;
68
+    }
69 69
 
70
-	protected function configure() {
71
-		$this
72
-			->setName('upgrade')
73
-			->setDescription('run upgrade routines after installation of a new release. The release has to be installed before.')
74
-			->addOption(
75
-				'--no-app-disable',
76
-				null,
77
-				InputOption::VALUE_NONE,
78
-				'skips the disable of third party apps'
79
-			);
80
-	}
70
+    protected function configure() {
71
+        $this
72
+            ->setName('upgrade')
73
+            ->setDescription('run upgrade routines after installation of a new release. The release has to be installed before.')
74
+            ->addOption(
75
+                '--no-app-disable',
76
+                null,
77
+                InputOption::VALUE_NONE,
78
+                'skips the disable of third party apps'
79
+            );
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(\OC::checkUpgrade(false)) {
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(\OC::checkUpgrade(false)) {
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
-			);
97
+            $self = $this;
98
+            $updater = new Updater(
99
+                    $this->config,
100
+                    \OC::$server->getIntegrityCodeChecker(),
101
+                    $this->logger
102
+            );
103 103
 
104
-			if ($input->getOption('no-app-disable')) {
105
-				$updater->setSkip3rdPartyAppsDisable(true);
106
-			}
107
-			$dispatcher = \OC::$server->getEventDispatcher();
108
-			$progress = new ProgressBar($output);
109
-			$progress->setFormat(" %message%\n %current%/%max% [%bar%] %percent:3s%%");
110
-			$listener = function($event) use ($progress, $output) {
111
-				if ($event instanceof GenericEvent) {
112
-					$message = $event->getSubject();
113
-					if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
114
-						$output->writeln(' Checking table ' . $message);
115
-					} else {
116
-						if (strlen($message) > 60) {
117
-							$message = substr($message, 0, 57) . '...';
118
-						}
119
-						$progress->setMessage($message);
120
-						if ($event[0] === 1) {
121
-							$output->writeln('');
122
-							$progress->start($event[1]);
123
-						}
124
-						$progress->setProgress($event[0]);
125
-						if ($event[0] === $event[1]) {
126
-							$progress->setMessage('Done');
127
-							$progress->finish();
128
-							$output->writeln('');
129
-						}
130
-					}
131
-				}
132
-			};
133
-			$repairListener = function($event) use ($progress, $output) {
134
-				if (!$event instanceof GenericEvent) {
135
-					return;
136
-				}
137
-				switch ($event->getSubject()) {
138
-					case '\OC\Repair::startProgress':
139
-						$progress->setMessage('Starting ...');
140
-						$output->writeln($event->getArgument(1));
141
-						$output->writeln('');
142
-						$progress->start($event->getArgument(0));
143
-						break;
144
-					case '\OC\Repair::advance':
145
-						$desc = $event->getArgument(1);
146
-						if (!empty($desc)) {
147
-							$progress->setMessage($desc);
148
-						}
149
-						$progress->advance($event->getArgument(0));
104
+            if ($input->getOption('no-app-disable')) {
105
+                $updater->setSkip3rdPartyAppsDisable(true);
106
+            }
107
+            $dispatcher = \OC::$server->getEventDispatcher();
108
+            $progress = new ProgressBar($output);
109
+            $progress->setFormat(" %message%\n %current%/%max% [%bar%] %percent:3s%%");
110
+            $listener = function($event) use ($progress, $output) {
111
+                if ($event instanceof GenericEvent) {
112
+                    $message = $event->getSubject();
113
+                    if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
114
+                        $output->writeln(' Checking table ' . $message);
115
+                    } else {
116
+                        if (strlen($message) > 60) {
117
+                            $message = substr($message, 0, 57) . '...';
118
+                        }
119
+                        $progress->setMessage($message);
120
+                        if ($event[0] === 1) {
121
+                            $output->writeln('');
122
+                            $progress->start($event[1]);
123
+                        }
124
+                        $progress->setProgress($event[0]);
125
+                        if ($event[0] === $event[1]) {
126
+                            $progress->setMessage('Done');
127
+                            $progress->finish();
128
+                            $output->writeln('');
129
+                        }
130
+                    }
131
+                }
132
+            };
133
+            $repairListener = function($event) use ($progress, $output) {
134
+                if (!$event instanceof GenericEvent) {
135
+                    return;
136
+                }
137
+                switch ($event->getSubject()) {
138
+                    case '\OC\Repair::startProgress':
139
+                        $progress->setMessage('Starting ...');
140
+                        $output->writeln($event->getArgument(1));
141
+                        $output->writeln('');
142
+                        $progress->start($event->getArgument(0));
143
+                        break;
144
+                    case '\OC\Repair::advance':
145
+                        $desc = $event->getArgument(1);
146
+                        if (!empty($desc)) {
147
+                            $progress->setMessage($desc);
148
+                        }
149
+                        $progress->advance($event->getArgument(0));
150 150
 
151
-						break;
152
-					case '\OC\Repair::finishProgress':
153
-						$progress->setMessage('Done');
154
-						$progress->finish();
155
-						$output->writeln('');
156
-						break;
157
-					case '\OC\Repair::step':
158
-						if(OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
159
-							$output->writeln('<info>Repair step: ' . $event->getArgument(0) . '</info>');
160
-						}
161
-						break;
162
-					case '\OC\Repair::info':
163
-						if(OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
164
-							$output->writeln('<info>Repair info: ' . $event->getArgument(0) . '</info>');
165
-						}
166
-						break;
167
-					case '\OC\Repair::warning':
168
-						$output->writeln('<error>Repair warning: ' . $event->getArgument(0) . '</error>');
169
-						break;
170
-					case '\OC\Repair::error':
171
-						$output->writeln('<error>Repair error: ' . $event->getArgument(0) . '</error>');
172
-						break;
173
-				}
174
-			};
151
+                        break;
152
+                    case '\OC\Repair::finishProgress':
153
+                        $progress->setMessage('Done');
154
+                        $progress->finish();
155
+                        $output->writeln('');
156
+                        break;
157
+                    case '\OC\Repair::step':
158
+                        if(OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
159
+                            $output->writeln('<info>Repair step: ' . $event->getArgument(0) . '</info>');
160
+                        }
161
+                        break;
162
+                    case '\OC\Repair::info':
163
+                        if(OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
164
+                            $output->writeln('<info>Repair info: ' . $event->getArgument(0) . '</info>');
165
+                        }
166
+                        break;
167
+                    case '\OC\Repair::warning':
168
+                        $output->writeln('<error>Repair warning: ' . $event->getArgument(0) . '</error>');
169
+                        break;
170
+                    case '\OC\Repair::error':
171
+                        $output->writeln('<error>Repair error: ' . $event->getArgument(0) . '</error>');
172
+                        break;
173
+                }
174
+            };
175 175
 
176
-			$dispatcher->addListener('\OC\DB\Migrator::executeSql', $listener);
177
-			$dispatcher->addListener('\OC\DB\Migrator::checkTable', $listener);
178
-			$dispatcher->addListener('\OC\Repair::startProgress', $repairListener);
179
-			$dispatcher->addListener('\OC\Repair::advance', $repairListener);
180
-			$dispatcher->addListener('\OC\Repair::finishProgress', $repairListener);
181
-			$dispatcher->addListener('\OC\Repair::step', $repairListener);
182
-			$dispatcher->addListener('\OC\Repair::info', $repairListener);
183
-			$dispatcher->addListener('\OC\Repair::warning', $repairListener);
184
-			$dispatcher->addListener('\OC\Repair::error', $repairListener);
176
+            $dispatcher->addListener('\OC\DB\Migrator::executeSql', $listener);
177
+            $dispatcher->addListener('\OC\DB\Migrator::checkTable', $listener);
178
+            $dispatcher->addListener('\OC\Repair::startProgress', $repairListener);
179
+            $dispatcher->addListener('\OC\Repair::advance', $repairListener);
180
+            $dispatcher->addListener('\OC\Repair::finishProgress', $repairListener);
181
+            $dispatcher->addListener('\OC\Repair::step', $repairListener);
182
+            $dispatcher->addListener('\OC\Repair::info', $repairListener);
183
+            $dispatcher->addListener('\OC\Repair::warning', $repairListener);
184
+            $dispatcher->addListener('\OC\Repair::error', $repairListener);
185 185
 			
186 186
 
187
-			$updater->listen('\OC\Updater', 'maintenanceEnabled', function () use($output) {
188
-				$output->writeln('<info>Turned on maintenance mode</info>');
189
-			});
190
-			$updater->listen('\OC\Updater', 'maintenanceDisabled', function () use($output) {
191
-				$output->writeln('<info>Turned off maintenance mode</info>');
192
-			});
193
-			$updater->listen('\OC\Updater', 'maintenanceActive', function () use($output) {
194
-				$output->writeln('<info>Maintenance mode is kept active</info>');
195
-			});
196
-			$updater->listen('\OC\Updater', 'updateEnd',
197
-				function ($success) use($output, $self) {
198
-					if ($success) {
199
-						$message = "<info>Update successful</info>";
200
-					} else {
201
-						$message = "<error>Update failed</error>";
202
-					}
203
-					$output->writeln($message);
204
-				});
205
-			$updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use($output) {
206
-				$output->writeln('<info>Updating database schema</info>');
207
-			});
208
-			$updater->listen('\OC\Updater', 'dbUpgrade', function () use($output) {
209
-				$output->writeln('<info>Updated database</info>');
210
-			});
211
-			$updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($output) {
212
-				$output->writeln('<info>Checking whether the database schema can be updated (this can take a long time depending on the database size)</info>');
213
-			});
214
-			$updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use($output) {
215
-				$output->writeln('<info>Checked database schema update</info>');
216
-			});
217
-			$updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use($output) {
218
-				$output->writeln('<comment>Disabled incompatible app: ' . $app . '</comment>');
219
-			});
220
-			$updater->listen('\OC\Updater', 'thirdPartyAppDisabled', function ($app) use ($output) {
221
-				$output->writeln('<comment>Disabled 3rd-party app: ' . $app . '</comment>');
222
-			});
223
-			$updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use($output) {
224
-				$output->writeln('<info>Checking for update of app ' . $app . ' in appstore</info>');
225
-			});
226
-			$updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use($output) {
227
-				$output->writeln('<info>Update app ' . $app . ' from appstore</info>');
228
-			});
229
-			$updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use($output) {
230
-				$output->writeln('<info>Checked for update of app "' . $app . '" in appstore </info>');
231
-			});
232
-			$updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($output) {
233
-				$output->writeln('<info>Checking updates of apps</info>');
234
-			});
235
-			$updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($output) {
236
-				$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>");
237
-			});
238
-			$updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($output) {
239
-				$output->writeln('<info>Checked database schema update for apps</info>');
240
-			});
241
-			$updater->listen('\OC\Updater', 'appUpgradeStarted', function ($app, $version) use ($output) {
242
-				$output->writeln("<info>Updating <$app> ...</info>");
243
-			});
244
-			$updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($output) {
245
-				$output->writeln("<info>Updated <$app> to $version</info>");
246
-			});
247
-			$updater->listen('\OC\Updater', 'failure', function ($message) use($output, $self) {
248
-				$output->writeln("<error>$message</error>");
249
-			});
250
-			$updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use($output) {
251
-				$output->writeln("<info>Set log level to debug</info>");
252
-			});
253
-			$updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($output) {
254
-				$output->writeln("<info>Reset log level</info>");
255
-			});
256
-			$updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use($output) {
257
-				$output->writeln("<info>Starting code integrity check...</info>");
258
-			});
259
-			$updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use($output) {
260
-				$output->writeln("<info>Finished code integrity check</info>");
261
-			});
187
+            $updater->listen('\OC\Updater', 'maintenanceEnabled', function () use($output) {
188
+                $output->writeln('<info>Turned on maintenance mode</info>');
189
+            });
190
+            $updater->listen('\OC\Updater', 'maintenanceDisabled', function () use($output) {
191
+                $output->writeln('<info>Turned off maintenance mode</info>');
192
+            });
193
+            $updater->listen('\OC\Updater', 'maintenanceActive', function () use($output) {
194
+                $output->writeln('<info>Maintenance mode is kept active</info>');
195
+            });
196
+            $updater->listen('\OC\Updater', 'updateEnd',
197
+                function ($success) use($output, $self) {
198
+                    if ($success) {
199
+                        $message = "<info>Update successful</info>";
200
+                    } else {
201
+                        $message = "<error>Update failed</error>";
202
+                    }
203
+                    $output->writeln($message);
204
+                });
205
+            $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use($output) {
206
+                $output->writeln('<info>Updating database schema</info>');
207
+            });
208
+            $updater->listen('\OC\Updater', 'dbUpgrade', function () use($output) {
209
+                $output->writeln('<info>Updated database</info>');
210
+            });
211
+            $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($output) {
212
+                $output->writeln('<info>Checking whether the database schema can be updated (this can take a long time depending on the database size)</info>');
213
+            });
214
+            $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use($output) {
215
+                $output->writeln('<info>Checked database schema update</info>');
216
+            });
217
+            $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use($output) {
218
+                $output->writeln('<comment>Disabled incompatible app: ' . $app . '</comment>');
219
+            });
220
+            $updater->listen('\OC\Updater', 'thirdPartyAppDisabled', function ($app) use ($output) {
221
+                $output->writeln('<comment>Disabled 3rd-party app: ' . $app . '</comment>');
222
+            });
223
+            $updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use($output) {
224
+                $output->writeln('<info>Checking for update of app ' . $app . ' in appstore</info>');
225
+            });
226
+            $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use($output) {
227
+                $output->writeln('<info>Update app ' . $app . ' from appstore</info>');
228
+            });
229
+            $updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use($output) {
230
+                $output->writeln('<info>Checked for update of app "' . $app . '" in appstore </info>');
231
+            });
232
+            $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($output) {
233
+                $output->writeln('<info>Checking updates of apps</info>');
234
+            });
235
+            $updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($output) {
236
+                $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>");
237
+            });
238
+            $updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($output) {
239
+                $output->writeln('<info>Checked database schema update for apps</info>');
240
+            });
241
+            $updater->listen('\OC\Updater', 'appUpgradeStarted', function ($app, $version) use ($output) {
242
+                $output->writeln("<info>Updating <$app> ...</info>");
243
+            });
244
+            $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($output) {
245
+                $output->writeln("<info>Updated <$app> to $version</info>");
246
+            });
247
+            $updater->listen('\OC\Updater', 'failure', function ($message) use($output, $self) {
248
+                $output->writeln("<error>$message</error>");
249
+            });
250
+            $updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use($output) {
251
+                $output->writeln("<info>Set log level to debug</info>");
252
+            });
253
+            $updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($output) {
254
+                $output->writeln("<info>Reset log level</info>");
255
+            });
256
+            $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use($output) {
257
+                $output->writeln("<info>Starting code integrity check...</info>");
258
+            });
259
+            $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use($output) {
260
+                $output->writeln("<info>Finished code integrity check</info>");
261
+            });
262 262
 
263
-			$success = $updater->upgrade();
263
+            $success = $updater->upgrade();
264 264
 
265
-			$this->postUpgradeCheck($input, $output);
265
+            $this->postUpgradeCheck($input, $output);
266 266
 
267
-			if(!$success) {
268
-				return self::ERROR_FAILURE;
269
-			}
267
+            if(!$success) {
268
+                return self::ERROR_FAILURE;
269
+            }
270 270
 
271
-			return self::ERROR_SUCCESS;
272
-		} else if($this->config->getSystemValue('maintenance', false)) {
273
-			//Possible scenario: Nextcloud core is updated but an app failed
274
-			$output->writeln('<warning>Nextcloud is in maintenance mode</warning>');
275
-			$output->write('<comment>Maybe an upgrade is already in process. Please check the '
276
-				. 'logfile (data/nextcloud.log). If you want to re-run the '
277
-				. 'upgrade procedure, remove the "maintenance mode" from '
278
-				. 'config.php and call this script again.</comment>'
279
-				, true);
280
-			return self::ERROR_MAINTENANCE_MODE;
281
-		} else {
282
-			$output->writeln('<info>Nextcloud is already latest version</info>');
283
-			return self::ERROR_UP_TO_DATE;
284
-		}
285
-	}
271
+            return self::ERROR_SUCCESS;
272
+        } else if($this->config->getSystemValue('maintenance', false)) {
273
+            //Possible scenario: Nextcloud core is updated but an app failed
274
+            $output->writeln('<warning>Nextcloud is in maintenance mode</warning>');
275
+            $output->write('<comment>Maybe an upgrade is already in process. Please check the '
276
+                . 'logfile (data/nextcloud.log). If you want to re-run the '
277
+                . 'upgrade procedure, remove the "maintenance mode" from '
278
+                . 'config.php and call this script again.</comment>'
279
+                , true);
280
+            return self::ERROR_MAINTENANCE_MODE;
281
+        } else {
282
+            $output->writeln('<info>Nextcloud is already latest version</info>');
283
+            return self::ERROR_UP_TO_DATE;
284
+        }
285
+    }
286 286
 
287
-	/**
288
-	 * Perform a post upgrade check (specific to the command line tool)
289
-	 *
290
-	 * @param InputInterface $input input interface
291
-	 * @param OutputInterface $output output interface
292
-	 */
293
-	protected function postUpgradeCheck(InputInterface $input, OutputInterface $output) {
294
-		$trustedDomains = $this->config->getSystemValue('trusted_domains', array());
295
-		if (empty($trustedDomains)) {
296
-			$output->write(
297
-				'<warning>The setting "trusted_domains" could not be ' .
298
-				'set automatically by the upgrade script, ' .
299
-				'please set it manually</warning>'
300
-			);
301
-		}
302
-	}
287
+    /**
288
+     * Perform a post upgrade check (specific to the command line tool)
289
+     *
290
+     * @param InputInterface $input input interface
291
+     * @param OutputInterface $output output interface
292
+     */
293
+    protected function postUpgradeCheck(InputInterface $input, OutputInterface $output) {
294
+        $trustedDomains = $this->config->getSystemValue('trusted_domains', array());
295
+        if (empty($trustedDomains)) {
296
+            $output->write(
297
+                '<warning>The setting "trusted_domains" could not be ' .
298
+                'set automatically by the upgrade script, ' .
299
+                'please set it manually</warning>'
300
+            );
301
+        }
302
+    }
303 303
 }
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 */
88 88
 	protected function execute(InputInterface $input, OutputInterface $output) {
89 89
 
90
-		if(\OC::checkUpgrade(false)) {
90
+		if (\OC::checkUpgrade(false)) {
91 91
 			if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
92 92
 				// Prepend each line with a little timestamp
93 93
 				$timestampFormatter = new TimestampFormatter($this->config, $output->getFormatter());
@@ -111,10 +111,10 @@  discard block
 block discarded – undo
111 111
 				if ($event instanceof GenericEvent) {
112 112
 					$message = $event->getSubject();
113 113
 					if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
114
-						$output->writeln(' Checking table ' . $message);
114
+						$output->writeln(' Checking table '.$message);
115 115
 					} else {
116 116
 						if (strlen($message) > 60) {
117
-							$message = substr($message, 0, 57) . '...';
117
+							$message = substr($message, 0, 57).'...';
118 118
 						}
119 119
 						$progress->setMessage($message);
120 120
 						if ($event[0] === 1) {
@@ -155,20 +155,20 @@  discard block
 block discarded – undo
155 155
 						$output->writeln('');
156 156
 						break;
157 157
 					case '\OC\Repair::step':
158
-						if(OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
159
-							$output->writeln('<info>Repair step: ' . $event->getArgument(0) . '</info>');
158
+						if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
159
+							$output->writeln('<info>Repair step: '.$event->getArgument(0).'</info>');
160 160
 						}
161 161
 						break;
162 162
 					case '\OC\Repair::info':
163
-						if(OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
164
-							$output->writeln('<info>Repair info: ' . $event->getArgument(0) . '</info>');
163
+						if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
164
+							$output->writeln('<info>Repair info: '.$event->getArgument(0).'</info>');
165 165
 						}
166 166
 						break;
167 167
 					case '\OC\Repair::warning':
168
-						$output->writeln('<error>Repair warning: ' . $event->getArgument(0) . '</error>');
168
+						$output->writeln('<error>Repair warning: '.$event->getArgument(0).'</error>');
169 169
 						break;
170 170
 					case '\OC\Repair::error':
171
-						$output->writeln('<error>Repair error: ' . $event->getArgument(0) . '</error>');
171
+						$output->writeln('<error>Repair error: '.$event->getArgument(0).'</error>');
172 172
 						break;
173 173
 				}
174 174
 			};
@@ -184,17 +184,17 @@  discard block
 block discarded – undo
184 184
 			$dispatcher->addListener('\OC\Repair::error', $repairListener);
185 185
 			
186 186
 
187
-			$updater->listen('\OC\Updater', 'maintenanceEnabled', function () use($output) {
187
+			$updater->listen('\OC\Updater', 'maintenanceEnabled', function() use($output) {
188 188
 				$output->writeln('<info>Turned on maintenance mode</info>');
189 189
 			});
190
-			$updater->listen('\OC\Updater', 'maintenanceDisabled', function () use($output) {
190
+			$updater->listen('\OC\Updater', 'maintenanceDisabled', function() use($output) {
191 191
 				$output->writeln('<info>Turned off maintenance mode</info>');
192 192
 			});
193
-			$updater->listen('\OC\Updater', 'maintenanceActive', function () use($output) {
193
+			$updater->listen('\OC\Updater', 'maintenanceActive', function() use($output) {
194 194
 				$output->writeln('<info>Maintenance mode is kept active</info>');
195 195
 			});
196 196
 			$updater->listen('\OC\Updater', 'updateEnd',
197
-				function ($success) use($output, $self) {
197
+				function($success) use($output, $self) {
198 198
 					if ($success) {
199 199
 						$message = "<info>Update successful</info>";
200 200
 					} else {
@@ -202,61 +202,61 @@  discard block
 block discarded – undo
202 202
 					}
203 203
 					$output->writeln($message);
204 204
 				});
205
-			$updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use($output) {
205
+			$updater->listen('\OC\Updater', 'dbUpgradeBefore', function() use($output) {
206 206
 				$output->writeln('<info>Updating database schema</info>');
207 207
 			});
208
-			$updater->listen('\OC\Updater', 'dbUpgrade', function () use($output) {
208
+			$updater->listen('\OC\Updater', 'dbUpgrade', function() use($output) {
209 209
 				$output->writeln('<info>Updated database</info>');
210 210
 			});
211
-			$updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($output) {
211
+			$updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function() use($output) {
212 212
 				$output->writeln('<info>Checking whether the database schema can be updated (this can take a long time depending on the database size)</info>');
213 213
 			});
214
-			$updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use($output) {
214
+			$updater->listen('\OC\Updater', 'dbSimulateUpgrade', function() use($output) {
215 215
 				$output->writeln('<info>Checked database schema update</info>');
216 216
 			});
217
-			$updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use($output) {
218
-				$output->writeln('<comment>Disabled incompatible app: ' . $app . '</comment>');
217
+			$updater->listen('\OC\Updater', 'incompatibleAppDisabled', function($app) use($output) {
218
+				$output->writeln('<comment>Disabled incompatible app: '.$app.'</comment>');
219 219
 			});
220
-			$updater->listen('\OC\Updater', 'thirdPartyAppDisabled', function ($app) use ($output) {
221
-				$output->writeln('<comment>Disabled 3rd-party app: ' . $app . '</comment>');
220
+			$updater->listen('\OC\Updater', 'thirdPartyAppDisabled', function($app) use ($output) {
221
+				$output->writeln('<comment>Disabled 3rd-party app: '.$app.'</comment>');
222 222
 			});
223
-			$updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use($output) {
224
-				$output->writeln('<info>Checking for update of app ' . $app . ' in appstore</info>');
223
+			$updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function($app) use($output) {
224
+				$output->writeln('<info>Checking for update of app '.$app.' in appstore</info>');
225 225
 			});
226
-			$updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use($output) {
227
-				$output->writeln('<info>Update app ' . $app . ' from appstore</info>');
226
+			$updater->listen('\OC\Updater', 'upgradeAppStoreApp', function($app) use($output) {
227
+				$output->writeln('<info>Update app '.$app.' from appstore</info>');
228 228
 			});
229
-			$updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use($output) {
230
-				$output->writeln('<info>Checked for update of app "' . $app . '" in appstore </info>');
229
+			$updater->listen('\OC\Updater', 'checkAppStoreApp', function($app) use($output) {
230
+				$output->writeln('<info>Checked for update of app "'.$app.'" in appstore </info>');
231 231
 			});
232
-			$updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($output) {
232
+			$updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function() use ($output) {
233 233
 				$output->writeln('<info>Checking updates of apps</info>');
234 234
 			});
235
-			$updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($output) {
235
+			$updater->listen('\OC\Updater', 'appSimulateUpdate', function($app) use ($output) {
236 236
 				$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>");
237 237
 			});
238
-			$updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($output) {
238
+			$updater->listen('\OC\Updater', 'appUpgradeCheck', function() use ($output) {
239 239
 				$output->writeln('<info>Checked database schema update for apps</info>');
240 240
 			});
241
-			$updater->listen('\OC\Updater', 'appUpgradeStarted', function ($app, $version) use ($output) {
241
+			$updater->listen('\OC\Updater', 'appUpgradeStarted', function($app, $version) use ($output) {
242 242
 				$output->writeln("<info>Updating <$app> ...</info>");
243 243
 			});
244
-			$updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($output) {
244
+			$updater->listen('\OC\Updater', 'appUpgrade', function($app, $version) use ($output) {
245 245
 				$output->writeln("<info>Updated <$app> to $version</info>");
246 246
 			});
247
-			$updater->listen('\OC\Updater', 'failure', function ($message) use($output, $self) {
247
+			$updater->listen('\OC\Updater', 'failure', function($message) use($output, $self) {
248 248
 				$output->writeln("<error>$message</error>");
249 249
 			});
250
-			$updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use($output) {
250
+			$updater->listen('\OC\Updater', 'setDebugLogLevel', function($logLevel, $logLevelName) use($output) {
251 251
 				$output->writeln("<info>Set log level to debug</info>");
252 252
 			});
253
-			$updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($output) {
253
+			$updater->listen('\OC\Updater', 'resetLogLevel', function($logLevel, $logLevelName) use($output) {
254 254
 				$output->writeln("<info>Reset log level</info>");
255 255
 			});
256
-			$updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use($output) {
256
+			$updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function() use($output) {
257 257
 				$output->writeln("<info>Starting code integrity check...</info>");
258 258
 			});
259
-			$updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use($output) {
259
+			$updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function() use($output) {
260 260
 				$output->writeln("<info>Finished code integrity check</info>");
261 261
 			});
262 262
 
@@ -264,12 +264,12 @@  discard block
 block discarded – undo
264 264
 
265 265
 			$this->postUpgradeCheck($input, $output);
266 266
 
267
-			if(!$success) {
267
+			if (!$success) {
268 268
 				return self::ERROR_FAILURE;
269 269
 			}
270 270
 
271 271
 			return self::ERROR_SUCCESS;
272
-		} else if($this->config->getSystemValue('maintenance', false)) {
272
+		} else if ($this->config->getSystemValue('maintenance', false)) {
273 273
 			//Possible scenario: Nextcloud core is updated but an app failed
274 274
 			$output->writeln('<warning>Nextcloud is in maintenance mode</warning>');
275 275
 			$output->write('<comment>Maybe an upgrade is already in process. Please check the '
@@ -294,8 +294,8 @@  discard block
 block discarded – undo
294 294
 		$trustedDomains = $this->config->getSystemValue('trusted_domains', array());
295 295
 		if (empty($trustedDomains)) {
296 296
 			$output->write(
297
-				'<warning>The setting "trusted_domains" could not be ' .
298
-				'set automatically by the upgrade script, ' .
297
+				'<warning>The setting "trusted_domains" could not be '.
298
+				'set automatically by the upgrade script, '.
299 299
 				'please set it manually</warning>'
300 300
 			);
301 301
 		}
Please login to merge, or discard this patch.