Completed
Push — master ( 5d4cc4...0ef15f )
by Joas
15:32 queued 02:35
created
lib/private/Repair/NC12/UpdateLanguageCodes.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,6 @@
 block discarded – undo
32 32
 	private $connection;
33 33
 
34 34
 	/**
35
-	 * @param IDBConnection $db
36 35
 	 */
37 36
 	public function __construct(IDBConnection $connection) {
38 37
 		$this->connection = $connection;
Please login to merge, or discard this patch.
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -28,48 +28,48 @@
 block discarded – undo
28 28
 use OCP\Migration\IRepairStep;
29 29
 
30 30
 class UpdateLanguageCodes implements IRepairStep {
31
-	/** @var IDBConnection */
32
-	private $connection;
31
+    /** @var IDBConnection */
32
+    private $connection;
33 33
 
34
-	/**
35
-	 * @param IDBConnection $db
36
-	 */
37
-	public function __construct(IDBConnection $connection) {
38
-		$this->connection = $connection;
39
-	}
34
+    /**
35
+     * @param IDBConnection $db
36
+     */
37
+    public function __construct(IDBConnection $connection) {
38
+        $this->connection = $connection;
39
+    }
40 40
 
41
-	/**
42
-	 * {@inheritdoc}
43
-	 */
44
-	public function getName() {
45
-		return 'Repair language codes';
46
-	}
41
+    /**
42
+     * {@inheritdoc}
43
+     */
44
+    public function getName() {
45
+        return 'Repair language codes';
46
+    }
47 47
 
48
-	/**
49
-	 * {@inheritdoc}
50
-	 */
51
-	public function run(IOutput $output) {
52
-		$languages = [
53
-			'bg_BG' => 'bg',
54
-			'cs_CZ' => 'cs',
55
-			'fi_FI' => 'fi',
56
-			'hu_HU' => 'hu',
57
-			'nb_NO' => 'nb',
58
-			'sk_SK' => 'sk',
59
-			'th_TH' => 'th',
60
-		];
48
+    /**
49
+     * {@inheritdoc}
50
+     */
51
+    public function run(IOutput $output) {
52
+        $languages = [
53
+            'bg_BG' => 'bg',
54
+            'cs_CZ' => 'cs',
55
+            'fi_FI' => 'fi',
56
+            'hu_HU' => 'hu',
57
+            'nb_NO' => 'nb',
58
+            'sk_SK' => 'sk',
59
+            'th_TH' => 'th',
60
+        ];
61 61
 
62
-		foreach ($languages as $oldCode => $newCode) {
63
-			$qb = $this->connection->getQueryBuilder();
62
+        foreach ($languages as $oldCode => $newCode) {
63
+            $qb = $this->connection->getQueryBuilder();
64 64
 
65
-			$affectedRows = $qb->update('preferences')
66
-				->set('configvalue', $qb->createNamedParameter($newCode))
67
-				->where($qb->expr()->eq('appid', $qb->createNamedParameter('core')))
68
-				->andWhere($qb->expr()->eq('configkey', $qb->createNamedParameter('lang')))
69
-				->andWhere($qb->expr()->eq('configvalue', $qb->createNamedParameter($oldCode)))
70
-				->execute();
65
+            $affectedRows = $qb->update('preferences')
66
+                ->set('configvalue', $qb->createNamedParameter($newCode))
67
+                ->where($qb->expr()->eq('appid', $qb->createNamedParameter('core')))
68
+                ->andWhere($qb->expr()->eq('configkey', $qb->createNamedParameter('lang')))
69
+                ->andWhere($qb->expr()->eq('configvalue', $qb->createNamedParameter($oldCode)))
70
+                ->execute();
71 71
 
72
-			$output->info('Changed ' . $affectedRows . ' setting(s) from "' . $oldCode . '" to "' . $newCode . '" in preferences table.');
73
-		}
74
-	}
72
+            $output->info('Changed ' . $affectedRows . ' setting(s) from "' . $oldCode . '" to "' . $newCode . '" in preferences table.');
73
+        }
74
+    }
75 75
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@
 block discarded – undo
69 69
 				->andWhere($qb->expr()->eq('configvalue', $qb->createNamedParameter($oldCode)))
70 70
 				->execute();
71 71
 
72
-			$output->info('Changed ' . $affectedRows . ' setting(s) from "' . $oldCode . '" to "' . $newCode . '" in preferences table.');
72
+			$output->info('Changed '.$affectedRows.' setting(s) from "'.$oldCode.'" to "'.$newCode.'" in preferences table.');
73 73
 		}
74 74
 	}
75 75
 }
Please login to merge, or discard this patch.
lib/private/Repair.php 1 patch
Indentation   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -49,171 +49,171 @@
 block discarded – undo
49 49
 use Symfony\Component\EventDispatcher\GenericEvent;
50 50
 
51 51
 class Repair implements IOutput{
52
-	/* @var IRepairStep[] */
53
-	private $repairSteps;
54
-	/** @var EventDispatcher */
55
-	private $dispatcher;
56
-	/** @var string */
57
-	private $currentStep;
58
-
59
-	/**
60
-	 * Creates a new repair step runner
61
-	 *
62
-	 * @param IRepairStep[] $repairSteps array of RepairStep instances
63
-	 * @param EventDispatcher $dispatcher
64
-	 */
65
-	public function __construct($repairSteps = [], EventDispatcher $dispatcher = null) {
66
-		$this->repairSteps = $repairSteps;
67
-		$this->dispatcher = $dispatcher;
68
-	}
69
-
70
-	/**
71
-	 * Run a series of repair steps for common problems
72
-	 */
73
-	public function run() {
74
-		if (count($this->repairSteps) === 0) {
75
-			$this->emit('\OC\Repair', 'info', array('No repair steps available'));
76
-			return;
77
-		}
78
-		// run each repair step
79
-		foreach ($this->repairSteps as $step) {
80
-			$this->currentStep = $step->getName();
81
-			$this->emit('\OC\Repair', 'step', [$this->currentStep]);
82
-			$step->run($this);
83
-		}
84
-	}
85
-
86
-	/**
87
-	 * Add repair step
88
-	 *
89
-	 * @param IRepairStep|string $repairStep repair step
90
-	 * @throws \Exception
91
-	 */
92
-	public function addStep($repairStep) {
93
-		if (is_string($repairStep)) {
94
-			try {
95
-				$s = \OC::$server->query($repairStep);
96
-			} catch (QueryException $e) {
97
-				if (class_exists($repairStep)) {
98
-					$s = new $repairStep();
99
-				} else {
100
-					throw new \Exception("Repair step '$repairStep' is unknown");
101
-				}
102
-			}
103
-
104
-			if ($s instanceof IRepairStep) {
105
-				$this->repairSteps[] = $s;
106
-			} else {
107
-				throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep");
108
-			}
109
-		} else {
110
-			$this->repairSteps[] = $repairStep;
111
-		}
112
-	}
113
-
114
-	/**
115
-	 * Returns the default repair steps to be run on the
116
-	 * command line or after an upgrade.
117
-	 *
118
-	 * @return IRepairStep[]
119
-	 */
120
-	public static function getRepairSteps() {
121
-		return [
122
-			new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->getDatabaseConnection(), false),
123
-			new RepairMimeTypes(\OC::$server->getConfig()),
124
-			new CleanTags(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager()),
125
-			new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
126
-			new RemoveRootShares(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager(), \OC::$server->getLazyRootFolder()),
127
-			new MoveUpdaterStepFile(\OC::$server->getConfig()),
128
-			new MoveAvatars(
129
-				\OC::$server->getJobList(),
130
-				\OC::$server->getConfig()
131
-			),
132
-			new CleanPreviews(
133
-				\OC::$server->getJobList(),
134
-				\OC::$server->getUserManager(),
135
-				\OC::$server->getConfig()
136
-			),
137
-			new FixMountStorages(\OC::$server->getDatabaseConnection()),
138
-			new UpdateLanguageCodes(\OC::$server->getDatabaseConnection()),
139
-		];
140
-	}
141
-
142
-	/**
143
-	 * Returns expensive repair steps to be run on the
144
-	 * command line with a special option.
145
-	 *
146
-	 * @return IRepairStep[]
147
-	 */
148
-	public static function getExpensiveRepairSteps() {
149
-		return [
150
-			new OldGroupMembershipShares(\OC::$server->getDatabaseConnection(), \OC::$server->getGroupManager()),
151
-		];
152
-	}
153
-
154
-	/**
155
-	 * Returns the repair steps to be run before an
156
-	 * upgrade.
157
-	 *
158
-	 * @return IRepairStep[]
159
-	 */
160
-	public static function getBeforeUpgradeRepairSteps() {
161
-		$connection = \OC::$server->getDatabaseConnection();
162
-		$steps = [
163
-			new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), $connection, true),
164
-			new SqliteAutoincrement($connection),
165
-		];
166
-
167
-		return $steps;
168
-	}
169
-
170
-	/**
171
-	 * @param string $scope
172
-	 * @param string $method
173
-	 * @param array $arguments
174
-	 */
175
-	public function emit($scope, $method, array $arguments = []) {
176
-		if (!is_null($this->dispatcher)) {
177
-			$this->dispatcher->dispatch("$scope::$method",
178
-				new GenericEvent("$scope::$method", $arguments));
179
-		}
180
-	}
181
-
182
-	public function info($string) {
183
-		// for now just emit as we did in the past
184
-		$this->emit('\OC\Repair', 'info', array($string));
185
-	}
186
-
187
-	/**
188
-	 * @param string $message
189
-	 */
190
-	public function warning($message) {
191
-		// for now just emit as we did in the past
192
-		$this->emit('\OC\Repair', 'warning', [$message]);
193
-	}
194
-
195
-	/**
196
-	 * @param int $max
197
-	 */
198
-	public function startProgress($max = 0) {
199
-		// for now just emit as we did in the past
200
-		$this->emit('\OC\Repair', 'startProgress', [$max, $this->currentStep]);
201
-	}
202
-
203
-	/**
204
-	 * @param int $step
205
-	 * @param string $description
206
-	 */
207
-	public function advance($step = 1, $description = '') {
208
-		// for now just emit as we did in the past
209
-		$this->emit('\OC\Repair', 'advance', [$step, $description]);
210
-	}
211
-
212
-	/**
213
-	 * @param int $max
214
-	 */
215
-	public function finishProgress() {
216
-		// for now just emit as we did in the past
217
-		$this->emit('\OC\Repair', 'finishProgress', []);
218
-	}
52
+    /* @var IRepairStep[] */
53
+    private $repairSteps;
54
+    /** @var EventDispatcher */
55
+    private $dispatcher;
56
+    /** @var string */
57
+    private $currentStep;
58
+
59
+    /**
60
+     * Creates a new repair step runner
61
+     *
62
+     * @param IRepairStep[] $repairSteps array of RepairStep instances
63
+     * @param EventDispatcher $dispatcher
64
+     */
65
+    public function __construct($repairSteps = [], EventDispatcher $dispatcher = null) {
66
+        $this->repairSteps = $repairSteps;
67
+        $this->dispatcher = $dispatcher;
68
+    }
69
+
70
+    /**
71
+     * Run a series of repair steps for common problems
72
+     */
73
+    public function run() {
74
+        if (count($this->repairSteps) === 0) {
75
+            $this->emit('\OC\Repair', 'info', array('No repair steps available'));
76
+            return;
77
+        }
78
+        // run each repair step
79
+        foreach ($this->repairSteps as $step) {
80
+            $this->currentStep = $step->getName();
81
+            $this->emit('\OC\Repair', 'step', [$this->currentStep]);
82
+            $step->run($this);
83
+        }
84
+    }
85
+
86
+    /**
87
+     * Add repair step
88
+     *
89
+     * @param IRepairStep|string $repairStep repair step
90
+     * @throws \Exception
91
+     */
92
+    public function addStep($repairStep) {
93
+        if (is_string($repairStep)) {
94
+            try {
95
+                $s = \OC::$server->query($repairStep);
96
+            } catch (QueryException $e) {
97
+                if (class_exists($repairStep)) {
98
+                    $s = new $repairStep();
99
+                } else {
100
+                    throw new \Exception("Repair step '$repairStep' is unknown");
101
+                }
102
+            }
103
+
104
+            if ($s instanceof IRepairStep) {
105
+                $this->repairSteps[] = $s;
106
+            } else {
107
+                throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep");
108
+            }
109
+        } else {
110
+            $this->repairSteps[] = $repairStep;
111
+        }
112
+    }
113
+
114
+    /**
115
+     * Returns the default repair steps to be run on the
116
+     * command line or after an upgrade.
117
+     *
118
+     * @return IRepairStep[]
119
+     */
120
+    public static function getRepairSteps() {
121
+        return [
122
+            new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->getDatabaseConnection(), false),
123
+            new RepairMimeTypes(\OC::$server->getConfig()),
124
+            new CleanTags(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager()),
125
+            new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
126
+            new RemoveRootShares(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager(), \OC::$server->getLazyRootFolder()),
127
+            new MoveUpdaterStepFile(\OC::$server->getConfig()),
128
+            new MoveAvatars(
129
+                \OC::$server->getJobList(),
130
+                \OC::$server->getConfig()
131
+            ),
132
+            new CleanPreviews(
133
+                \OC::$server->getJobList(),
134
+                \OC::$server->getUserManager(),
135
+                \OC::$server->getConfig()
136
+            ),
137
+            new FixMountStorages(\OC::$server->getDatabaseConnection()),
138
+            new UpdateLanguageCodes(\OC::$server->getDatabaseConnection()),
139
+        ];
140
+    }
141
+
142
+    /**
143
+     * Returns expensive repair steps to be run on the
144
+     * command line with a special option.
145
+     *
146
+     * @return IRepairStep[]
147
+     */
148
+    public static function getExpensiveRepairSteps() {
149
+        return [
150
+            new OldGroupMembershipShares(\OC::$server->getDatabaseConnection(), \OC::$server->getGroupManager()),
151
+        ];
152
+    }
153
+
154
+    /**
155
+     * Returns the repair steps to be run before an
156
+     * upgrade.
157
+     *
158
+     * @return IRepairStep[]
159
+     */
160
+    public static function getBeforeUpgradeRepairSteps() {
161
+        $connection = \OC::$server->getDatabaseConnection();
162
+        $steps = [
163
+            new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), $connection, true),
164
+            new SqliteAutoincrement($connection),
165
+        ];
166
+
167
+        return $steps;
168
+    }
169
+
170
+    /**
171
+     * @param string $scope
172
+     * @param string $method
173
+     * @param array $arguments
174
+     */
175
+    public function emit($scope, $method, array $arguments = []) {
176
+        if (!is_null($this->dispatcher)) {
177
+            $this->dispatcher->dispatch("$scope::$method",
178
+                new GenericEvent("$scope::$method", $arguments));
179
+        }
180
+    }
181
+
182
+    public function info($string) {
183
+        // for now just emit as we did in the past
184
+        $this->emit('\OC\Repair', 'info', array($string));
185
+    }
186
+
187
+    /**
188
+     * @param string $message
189
+     */
190
+    public function warning($message) {
191
+        // for now just emit as we did in the past
192
+        $this->emit('\OC\Repair', 'warning', [$message]);
193
+    }
194
+
195
+    /**
196
+     * @param int $max
197
+     */
198
+    public function startProgress($max = 0) {
199
+        // for now just emit as we did in the past
200
+        $this->emit('\OC\Repair', 'startProgress', [$max, $this->currentStep]);
201
+    }
202
+
203
+    /**
204
+     * @param int $step
205
+     * @param string $description
206
+     */
207
+    public function advance($step = 1, $description = '') {
208
+        // for now just emit as we did in the past
209
+        $this->emit('\OC\Repair', 'advance', [$step, $description]);
210
+    }
211
+
212
+    /**
213
+     * @param int $max
214
+     */
215
+    public function finishProgress() {
216
+        // for now just emit as we did in the past
217
+        $this->emit('\OC\Repair', 'finishProgress', []);
218
+    }
219 219
 }
Please login to merge, or discard this patch.