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