diff options
author | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-05-09 09:56:56 +0200 |
---|---|---|
committer | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-05-09 09:56:56 +0200 |
commit | a502de0d28c6c4d7ddd23f40ef0ab49f4782988a (patch) | |
tree | a4adfa9fbc3c07513355e58fa293357bc70e8f37 | |
parent | 5ff2d59cd47c279f02d882cad8bb31258e64ce2f (diff) | |
parent | dda949e915e9c70ea6797c4551cd101df7356f93 (diff) | |
download | nextcloud-server-a502de0d28c6c4d7ddd23f40ef0ab49f4782988a.tar.gz nextcloud-server-a502de0d28c6c4d7ddd23f40ef0ab49f4782988a.zip |
Merge pull request #24419 from owncloud/allow-di-for-migration-steps
Allow migration steps to use automatic DI
-rw-r--r-- | lib/private/Repair.php | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/private/Repair.php b/lib/private/Repair.php index 5d10cd582f0..38752ee1703 100644 --- a/lib/private/Repair.php +++ b/lib/private/Repair.php @@ -28,7 +28,6 @@ namespace OC; -use OC\Hooks\Emitter; use OC\Repair\AssetCache; use OC\Repair\CleanTags; use OC\Repair\Collation; @@ -45,6 +44,7 @@ use OC\Repair\RepairMimeTypes; use OC\Repair\SearchLuceneTables; use OC\Repair\UpdateOutdatedOcsIds; use OC\Repair\RepairInvalidShares; +use OCP\AppFramework\QueryException; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; use Symfony\Component\EventDispatcher\EventDispatcher; @@ -93,15 +93,20 @@ class Repair implements IOutput{ */ public function addStep($repairStep) { if (is_string($repairStep)) { - if (class_exists($repairStep)) { - $s = new $repairStep(); - if ($s instanceof IRepairStep) { - $this->repairSteps[] = $s; + try { + $s = \OC::$server->query($repairStep); + } catch (QueryException $e) { + if (class_exists($repairStep)) { + $s = new $repairStep(); } else { - throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep"); + throw new \Exception("Repair step '$repairStep' is unknown"); } + } + + if ($s instanceof IRepairStep) { + $this->repairSteps[] = $s; } else { - throw new \Exception("Repair step '$repairStep' is unknown"); + throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep"); } } else { $this->repairSteps[] = $repairStep; |