Passed
Push — master ( 265f74...df9be4 )
by Joas
14:42 queued 12s
created
lib/private/Repair.php 1 patch
Indentation   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -88,202 +88,202 @@
 block discarded – undo
88 88
 
89 89
 class Repair implements IOutput {
90 90
 
91
-	/** @var IRepairStep[] */
92
-	private $repairSteps;
91
+    /** @var IRepairStep[] */
92
+    private $repairSteps;
93 93
 
94
-	private IEventDispatcher $dispatcher;
94
+    private IEventDispatcher $dispatcher;
95 95
 
96
-	/** @var string */
97
-	private $currentStep;
96
+    /** @var string */
97
+    private $currentStep;
98 98
 
99
-	private LoggerInterface $logger;
99
+    private LoggerInterface $logger;
100 100
 
101
-	/**
102
-	 * Creates a new repair step runner
103
-	 *
104
-	 * @param IRepairStep[] $repairSteps array of RepairStep instances
105
-	 */
106
-	public function __construct(array $repairSteps, IEventDispatcher $dispatcher, LoggerInterface $logger) {
107
-		$this->repairSteps = $repairSteps;
108
-		$this->dispatcher = $dispatcher;
109
-		$this->logger = $logger;
110
-	}
101
+    /**
102
+     * Creates a new repair step runner
103
+     *
104
+     * @param IRepairStep[] $repairSteps array of RepairStep instances
105
+     */
106
+    public function __construct(array $repairSteps, IEventDispatcher $dispatcher, LoggerInterface $logger) {
107
+        $this->repairSteps = $repairSteps;
108
+        $this->dispatcher = $dispatcher;
109
+        $this->logger = $logger;
110
+    }
111 111
 
112
-	/**
113
-	 * Run a series of repair steps for common problems
114
-	 */
115
-	public function run() {
116
-		if (count($this->repairSteps) === 0) {
117
-			$this->dispatcher->dispatchTyped(new RepairInfoEvent('No repair steps available'));
112
+    /**
113
+     * Run a series of repair steps for common problems
114
+     */
115
+    public function run() {
116
+        if (count($this->repairSteps) === 0) {
117
+            $this->dispatcher->dispatchTyped(new RepairInfoEvent('No repair steps available'));
118 118
 
119
-			return;
120
-		}
121
-		// run each repair step
122
-		foreach ($this->repairSteps as $step) {
123
-			$this->currentStep = $step->getName();
124
-			$this->dispatcher->dispatchTyped(new RepairStepEvent($this->currentStep));
125
-			try {
126
-				$step->run($this);
127
-			} catch (\Exception $e) {
128
-				$this->logger->error("Exception while executing repair step " . $step->getName(), ['exception' => $e]);
129
-				$this->dispatcher->dispatchTyped(new RepairErrorEvent($e->getMessage()));
130
-			}
131
-		}
132
-	}
119
+            return;
120
+        }
121
+        // run each repair step
122
+        foreach ($this->repairSteps as $step) {
123
+            $this->currentStep = $step->getName();
124
+            $this->dispatcher->dispatchTyped(new RepairStepEvent($this->currentStep));
125
+            try {
126
+                $step->run($this);
127
+            } catch (\Exception $e) {
128
+                $this->logger->error("Exception while executing repair step " . $step->getName(), ['exception' => $e]);
129
+                $this->dispatcher->dispatchTyped(new RepairErrorEvent($e->getMessage()));
130
+            }
131
+        }
132
+    }
133 133
 
134
-	/**
135
-	 * Add repair step
136
-	 *
137
-	 * @param IRepairStep|string $repairStep repair step
138
-	 * @throws \Exception
139
-	 */
140
-	public function addStep($repairStep) {
141
-		if (is_string($repairStep)) {
142
-			try {
143
-				$s = \OC::$server->get($repairStep);
144
-			} catch (QueryException $e) {
145
-				if (class_exists($repairStep)) {
146
-					try {
147
-						// Last resort: hope there are no constructor arguments
148
-						$s = new $repairStep();
149
-					} catch (Throwable $inner) {
150
-						// Well, it was worth a try
151
-						throw new \Exception("Repair step '$repairStep' can't be instantiated: " . $e->getMessage(), 0, $e);
152
-					}
153
-				} else {
154
-					throw new \Exception("Repair step '$repairStep' is unknown", 0, $e);
155
-				}
156
-			}
134
+    /**
135
+     * Add repair step
136
+     *
137
+     * @param IRepairStep|string $repairStep repair step
138
+     * @throws \Exception
139
+     */
140
+    public function addStep($repairStep) {
141
+        if (is_string($repairStep)) {
142
+            try {
143
+                $s = \OC::$server->get($repairStep);
144
+            } catch (QueryException $e) {
145
+                if (class_exists($repairStep)) {
146
+                    try {
147
+                        // Last resort: hope there are no constructor arguments
148
+                        $s = new $repairStep();
149
+                    } catch (Throwable $inner) {
150
+                        // Well, it was worth a try
151
+                        throw new \Exception("Repair step '$repairStep' can't be instantiated: " . $e->getMessage(), 0, $e);
152
+                    }
153
+                } else {
154
+                    throw new \Exception("Repair step '$repairStep' is unknown", 0, $e);
155
+                }
156
+            }
157 157
 
158
-			if ($s instanceof IRepairStep) {
159
-				$this->repairSteps[] = $s;
160
-			} else {
161
-				throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep");
162
-			}
163
-		} else {
164
-			$this->repairSteps[] = $repairStep;
165
-		}
166
-	}
158
+            if ($s instanceof IRepairStep) {
159
+                $this->repairSteps[] = $s;
160
+            } else {
161
+                throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep");
162
+            }
163
+        } else {
164
+            $this->repairSteps[] = $repairStep;
165
+        }
166
+    }
167 167
 
168
-	/**
169
-	 * Returns the default repair steps to be run on the
170
-	 * command line or after an upgrade.
171
-	 *
172
-	 * @return IRepairStep[]
173
-	 */
174
-	public static function getRepairSteps() {
175
-		return [
176
-			new Collation(\OC::$server->getConfig(), \OC::$server->get(LoggerInterface::class), \OC::$server->getDatabaseConnection(), false),
177
-			new RepairMimeTypes(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
178
-			new CleanTags(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager()),
179
-			new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
180
-			new MoveUpdaterStepFile(\OC::$server->getConfig()),
181
-			new MoveAvatars(
182
-				\OC::$server->getJobList(),
183
-				\OC::$server->getConfig()
184
-			),
185
-			new CleanPreviews(
186
-				\OC::$server->getJobList(),
187
-				\OC::$server->getUserManager(),
188
-				\OC::$server->getConfig()
189
-			),
190
-			new MigrateOauthTables(\OC::$server->get(Connection::class)),
191
-			new FixMountStorages(\OC::$server->getDatabaseConnection()),
192
-			new UpdateLanguageCodes(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig()),
193
-			new AddLogRotateJob(\OC::$server->getJobList()),
194
-			new ClearFrontendCaches(\OC::$server->getMemCacheFactory(), \OC::$server->query(JSCombiner::class)),
195
-			\OCP\Server::get(ClearGeneratedAvatarCache::class),
196
-			new AddPreviewBackgroundCleanupJob(\OC::$server->getJobList()),
197
-			new AddCleanupUpdaterBackupsJob(\OC::$server->getJobList()),
198
-			new CleanupCardDAVPhotoCache(\OC::$server->getConfig(), \OC::$server->getAppDataDir('dav-photocache'), \OC::$server->get(LoggerInterface::class)),
199
-			new AddClenupLoginFlowV2BackgroundJob(\OC::$server->getJobList()),
200
-			new RemoveLinkShares(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getGroupManager(), \OC::$server->getNotificationManager(), \OC::$server->query(ITimeFactory::class)),
201
-			new ClearCollectionsAccessCache(\OC::$server->getConfig(), \OC::$server->query(IManager::class)),
202
-			\OCP\Server::get(ResetGeneratedAvatarFlag::class),
203
-			\OCP\Server::get(EncryptionLegacyCipher::class),
204
-			\OCP\Server::get(EncryptionMigration::class),
205
-			\OCP\Server::get(ShippedDashboardEnable::class),
206
-			\OCP\Server::get(AddBruteForceCleanupJob::class),
207
-			\OCP\Server::get(AddCheckForUserCertificatesJob::class),
208
-			\OCP\Server::get(RepairDavShares::class),
209
-			\OCP\Server::get(LookupServerSendCheck::class),
210
-			\OCP\Server::get(AddTokenCleanupJob::class),
211
-		];
212
-	}
168
+    /**
169
+     * Returns the default repair steps to be run on the
170
+     * command line or after an upgrade.
171
+     *
172
+     * @return IRepairStep[]
173
+     */
174
+    public static function getRepairSteps() {
175
+        return [
176
+            new Collation(\OC::$server->getConfig(), \OC::$server->get(LoggerInterface::class), \OC::$server->getDatabaseConnection(), false),
177
+            new RepairMimeTypes(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
178
+            new CleanTags(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager()),
179
+            new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
180
+            new MoveUpdaterStepFile(\OC::$server->getConfig()),
181
+            new MoveAvatars(
182
+                \OC::$server->getJobList(),
183
+                \OC::$server->getConfig()
184
+            ),
185
+            new CleanPreviews(
186
+                \OC::$server->getJobList(),
187
+                \OC::$server->getUserManager(),
188
+                \OC::$server->getConfig()
189
+            ),
190
+            new MigrateOauthTables(\OC::$server->get(Connection::class)),
191
+            new FixMountStorages(\OC::$server->getDatabaseConnection()),
192
+            new UpdateLanguageCodes(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig()),
193
+            new AddLogRotateJob(\OC::$server->getJobList()),
194
+            new ClearFrontendCaches(\OC::$server->getMemCacheFactory(), \OC::$server->query(JSCombiner::class)),
195
+            \OCP\Server::get(ClearGeneratedAvatarCache::class),
196
+            new AddPreviewBackgroundCleanupJob(\OC::$server->getJobList()),
197
+            new AddCleanupUpdaterBackupsJob(\OC::$server->getJobList()),
198
+            new CleanupCardDAVPhotoCache(\OC::$server->getConfig(), \OC::$server->getAppDataDir('dav-photocache'), \OC::$server->get(LoggerInterface::class)),
199
+            new AddClenupLoginFlowV2BackgroundJob(\OC::$server->getJobList()),
200
+            new RemoveLinkShares(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getGroupManager(), \OC::$server->getNotificationManager(), \OC::$server->query(ITimeFactory::class)),
201
+            new ClearCollectionsAccessCache(\OC::$server->getConfig(), \OC::$server->query(IManager::class)),
202
+            \OCP\Server::get(ResetGeneratedAvatarFlag::class),
203
+            \OCP\Server::get(EncryptionLegacyCipher::class),
204
+            \OCP\Server::get(EncryptionMigration::class),
205
+            \OCP\Server::get(ShippedDashboardEnable::class),
206
+            \OCP\Server::get(AddBruteForceCleanupJob::class),
207
+            \OCP\Server::get(AddCheckForUserCertificatesJob::class),
208
+            \OCP\Server::get(RepairDavShares::class),
209
+            \OCP\Server::get(LookupServerSendCheck::class),
210
+            \OCP\Server::get(AddTokenCleanupJob::class),
211
+        ];
212
+    }
213 213
 
214
-	/**
215
-	 * Returns expensive repair steps to be run on the
216
-	 * command line with a special option.
217
-	 *
218
-	 * @return IRepairStep[]
219
-	 */
220
-	public static function getExpensiveRepairSteps() {
221
-		return [
222
-			new OldGroupMembershipShares(\OC::$server->getDatabaseConnection(), \OC::$server->getGroupManager()),
223
-			\OC::$server->get(ValidatePhoneNumber::class),
224
-		];
225
-	}
214
+    /**
215
+     * Returns expensive repair steps to be run on the
216
+     * command line with a special option.
217
+     *
218
+     * @return IRepairStep[]
219
+     */
220
+    public static function getExpensiveRepairSteps() {
221
+        return [
222
+            new OldGroupMembershipShares(\OC::$server->getDatabaseConnection(), \OC::$server->getGroupManager()),
223
+            \OC::$server->get(ValidatePhoneNumber::class),
224
+        ];
225
+    }
226 226
 
227
-	/**
228
-	 * Returns the repair steps to be run before an
229
-	 * upgrade.
230
-	 *
231
-	 * @return IRepairStep[]
232
-	 */
233
-	public static function getBeforeUpgradeRepairSteps() {
234
-		/** @var Connection $connection */
235
-		$connection = \OC::$server->get(Connection::class);
236
-		/** @var ConnectionAdapter $connectionAdapter */
237
-		$connectionAdapter = \OC::$server->get(ConnectionAdapter::class);
238
-		$config = \OC::$server->getConfig();
239
-		$steps = [
240
-			new Collation(\OC::$server->getConfig(), \OC::$server->get(LoggerInterface::class), $connectionAdapter, true),
241
-			new SqliteAutoincrement($connection),
242
-			new SaveAccountsTableData($connectionAdapter, $config),
243
-			new DropAccountTermsTable($connectionAdapter),
244
-		];
227
+    /**
228
+     * Returns the repair steps to be run before an
229
+     * upgrade.
230
+     *
231
+     * @return IRepairStep[]
232
+     */
233
+    public static function getBeforeUpgradeRepairSteps() {
234
+        /** @var Connection $connection */
235
+        $connection = \OC::$server->get(Connection::class);
236
+        /** @var ConnectionAdapter $connectionAdapter */
237
+        $connectionAdapter = \OC::$server->get(ConnectionAdapter::class);
238
+        $config = \OC::$server->getConfig();
239
+        $steps = [
240
+            new Collation(\OC::$server->getConfig(), \OC::$server->get(LoggerInterface::class), $connectionAdapter, true),
241
+            new SqliteAutoincrement($connection),
242
+            new SaveAccountsTableData($connectionAdapter, $config),
243
+            new DropAccountTermsTable($connectionAdapter),
244
+        ];
245 245
 
246
-		return $steps;
247
-	}
246
+        return $steps;
247
+    }
248 248
 
249
-	/**
250
-	 * @param string $message
251
-	 */
252
-	public function info($message) {
253
-		// for now just emit as we did in the past
254
-		$this->dispatcher->dispatchTyped(new RepairInfoEvent($message));
255
-	}
249
+    /**
250
+     * @param string $message
251
+     */
252
+    public function info($message) {
253
+        // for now just emit as we did in the past
254
+        $this->dispatcher->dispatchTyped(new RepairInfoEvent($message));
255
+    }
256 256
 
257
-	/**
258
-	 * @param string $message
259
-	 */
260
-	public function warning($message) {
261
-		// for now just emit as we did in the past
262
-		$this->dispatcher->dispatchTyped(new RepairWarningEvent($message));
263
-	}
257
+    /**
258
+     * @param string $message
259
+     */
260
+    public function warning($message) {
261
+        // for now just emit as we did in the past
262
+        $this->dispatcher->dispatchTyped(new RepairWarningEvent($message));
263
+    }
264 264
 
265
-	/**
266
-	 * @param int $max
267
-	 */
268
-	public function startProgress($max = 0) {
269
-		// for now just emit as we did in the past
270
-		$this->dispatcher->dispatchTyped(new RepairStartEvent($max, $this->currentStep));
271
-	}
265
+    /**
266
+     * @param int $max
267
+     */
268
+    public function startProgress($max = 0) {
269
+        // for now just emit as we did in the past
270
+        $this->dispatcher->dispatchTyped(new RepairStartEvent($max, $this->currentStep));
271
+    }
272 272
 
273
-	/**
274
-	 * @param int $step number of step to advance
275
-	 * @param string $description
276
-	 */
277
-	public function advance($step = 1, $description = '') {
278
-		// for now just emit as we did in the past
279
-		$this->dispatcher->dispatchTyped(new RepairAdvanceEvent($step, $description));
280
-	}
273
+    /**
274
+     * @param int $step number of step to advance
275
+     * @param string $description
276
+     */
277
+    public function advance($step = 1, $description = '') {
278
+        // for now just emit as we did in the past
279
+        $this->dispatcher->dispatchTyped(new RepairAdvanceEvent($step, $description));
280
+    }
281 281
 
282
-	/**
283
-	 * @param int $max
284
-	 */
285
-	public function finishProgress() {
286
-		// for now just emit as we did in the past
287
-		$this->dispatcher->dispatchTyped(new RepairFinishEvent());
288
-	}
282
+    /**
283
+     * @param int $max
284
+     */
285
+    public function finishProgress() {
286
+        // for now just emit as we did in the past
287
+        $this->dispatcher->dispatchTyped(new RepairFinishEvent());
288
+    }
289 289
 }
Please login to merge, or discard this patch.
lib/private/Repair/ClearGeneratedAvatarCache.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -31,38 +31,38 @@
 block discarded – undo
31 31
 use OCP\Migration\IRepairStep;
32 32
 
33 33
 class ClearGeneratedAvatarCache implements IRepairStep {
34
-	protected AvatarManager $avatarManager;
35
-	private IConfig $config;
36
-	private IJobList $jobList;
34
+    protected AvatarManager $avatarManager;
35
+    private IConfig $config;
36
+    private IJobList $jobList;
37 37
 
38
-	public function __construct(IConfig $config, AvatarManager $avatarManager, IJobList $jobList) {
39
-		$this->config = $config;
40
-		$this->avatarManager = $avatarManager;
41
-		$this->jobList = $jobList;
42
-	}
38
+    public function __construct(IConfig $config, AvatarManager $avatarManager, IJobList $jobList) {
39
+        $this->config = $config;
40
+        $this->avatarManager = $avatarManager;
41
+        $this->jobList = $jobList;
42
+    }
43 43
 
44
-	public function getName(): string {
45
-		return 'Clear every generated avatar on major updates';
46
-	}
44
+    public function getName(): string {
45
+        return 'Clear every generated avatar on major updates';
46
+    }
47 47
 
48
-	/**
49
-	 * Check if this repair step should run
50
-	 */
51
-	private function shouldRun(): bool {
52
-		$versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0');
48
+    /**
49
+     * Check if this repair step should run
50
+     */
51
+    private function shouldRun(): bool {
52
+        $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0');
53 53
 
54
-		// was added to 25.0.0.10
55
-		return version_compare($versionFromBeforeUpdate, '25.0.0.10', '<=');
56
-	}
54
+        // was added to 25.0.0.10
55
+        return version_compare($versionFromBeforeUpdate, '25.0.0.10', '<=');
56
+    }
57 57
 
58
-	public function run(IOutput $output): void {
59
-		if ($this->shouldRun()) {
60
-			try {
61
-				$this->jobList->add(ClearGeneratedAvatarCacheJob::class, []);
62
-				$output->info('Avatar cache clearing job added');
63
-			} catch (\Exception $e) {
64
-				$output->warning('Unable to clear the avatar cache');
65
-			}
66
-		}
67
-	}
58
+    public function run(IOutput $output): void {
59
+        if ($this->shouldRun()) {
60
+            try {
61
+                $this->jobList->add(ClearGeneratedAvatarCacheJob::class, []);
62
+                $output->info('Avatar cache clearing job added');
63
+            } catch (\Exception $e) {
64
+                $output->warning('Unable to clear the avatar cache');
65
+            }
66
+        }
67
+    }
68 68
 }
Please login to merge, or discard this patch.
lib/private/Repair/ClearGeneratedAvatarCacheJob.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -25,14 +25,14 @@
 block discarded – undo
25 25
 use OC\Avatar\AvatarManager;
26 26
 
27 27
 class ClearGeneratedAvatarCacheJob extends QueuedJob {
28
-	protected AvatarManager $avatarManager;
28
+    protected AvatarManager $avatarManager;
29 29
 
30
-	public function __construct(ITimeFactory $timeFactory, AvatarManager $avatarManager) {
31
-		parent::__construct($timeFactory);
32
-		$this->avatarManager = $avatarManager;
33
-	}
30
+    public function __construct(ITimeFactory $timeFactory, AvatarManager $avatarManager) {
31
+        parent::__construct($timeFactory);
32
+        $this->avatarManager = $avatarManager;
33
+    }
34 34
 
35
-	public function run($argument) {
36
-		$this->avatarManager->clearCachedAvatars();
37
-	}
35
+    public function run($argument) {
36
+        $this->avatarManager->clearCachedAvatars();
37
+    }
38 38
 }
Please login to merge, or discard this patch.