Passed
Push — master ( 4e9cd2...bc8d14 )
by Roeland
19:16 queued 09:49
created
apps/provisioning_api/lib/Middleware/Exceptions/NotSubAdminException.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
 use OCP\AppFramework\Http;
6 6
 
7 7
 class NotSubAdminException extends \Exception {
8
-	public function __construct() {
9
-		parent::__construct('Logged in user must be at least a sub admin', Http::STATUS_FORBIDDEN);
10
-	}
8
+    public function __construct() {
9
+        parent::__construct('Logged in user must be at least a sub admin', Http::STATUS_FORBIDDEN);
10
+    }
11 11
 }
Please login to merge, or discard this patch.
core/Command/Status.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -28,23 +28,23 @@
 block discarded – undo
28 28
 use Symfony\Component\Console\Output\OutputInterface;
29 29
 
30 30
 class Status extends Base {
31
-	protected function configure() {
32
-		parent::configure();
31
+    protected function configure() {
32
+        parent::configure();
33 33
 
34
-		$this
35
-			->setName('status')
36
-			->setDescription('show some status information')
37
-		;
38
-	}
34
+        $this
35
+            ->setName('status')
36
+            ->setDescription('show some status information')
37
+        ;
38
+    }
39 39
 
40
-	protected function execute(InputInterface $input, OutputInterface $output) {
41
-		$values = [
42
-			'installed' => (bool) \OC::$server->getConfig()->getSystemValue('installed', false),
43
-			'version' => implode('.', \OCP\Util::getVersion()),
44
-			'versionstring' => \OC_Util::getVersionString(),
45
-			'edition' => '',
46
-		];
40
+    protected function execute(InputInterface $input, OutputInterface $output) {
41
+        $values = [
42
+            'installed' => (bool) \OC::$server->getConfig()->getSystemValue('installed', false),
43
+            'version' => implode('.', \OCP\Util::getVersion()),
44
+            'versionstring' => \OC_Util::getVersionString(),
45
+            'edition' => '',
46
+        ];
47 47
 
48
-		$this->writeArrayInOutputFormat($input, $output, $values);
49
-	}
48
+        $this->writeArrayInOutputFormat($input, $output, $values);
49
+    }
50 50
 }
Please login to merge, or discard this patch.
lib/private/L10N/L10NString.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,8 +61,7 @@
 block discarded – undo
61 61
 				$fn = $this->l10n->getPluralFormFunction();
62 62
 				$id = $fn($this->count);
63 63
 				$text = $translations[$this->text][$id];
64
-			}
65
-			else{
64
+			} else{
66 65
 				$text = $translations[$this->text];
67 66
 			}
68 67
 		}
Please login to merge, or discard this patch.
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -29,59 +29,59 @@
 block discarded – undo
29 29
 namespace OC\L10N;
30 30
 
31 31
 class L10NString implements \JsonSerializable {
32
-	/** @var \OC\L10N\L10N */
33
-	protected $l10n;
32
+    /** @var \OC\L10N\L10N */
33
+    protected $l10n;
34 34
 
35
-	/** @var string */
36
-	protected $text;
35
+    /** @var string */
36
+    protected $text;
37 37
 
38
-	/** @var array */
39
-	protected $parameters;
38
+    /** @var array */
39
+    protected $parameters;
40 40
 
41
-	/** @var integer */
42
-	protected $count;
41
+    /** @var integer */
42
+    protected $count;
43 43
 
44
-	/**
45
-	 * @param \OC\L10N\L10N $l10n
46
-	 * @param string|string[] $text
47
-	 * @param array $parameters
48
-	 * @param int $count
49
-	 */
50
-	public function __construct(\OC\L10N\L10N $l10n, $text, $parameters, $count = 1) {
51
-		$this->l10n = $l10n;
52
-		$this->text = $text;
53
-		$this->parameters = $parameters;
54
-		$this->count = $count;
55
-	}
44
+    /**
45
+     * @param \OC\L10N\L10N $l10n
46
+     * @param string|string[] $text
47
+     * @param array $parameters
48
+     * @param int $count
49
+     */
50
+    public function __construct(\OC\L10N\L10N $l10n, $text, $parameters, $count = 1) {
51
+        $this->l10n = $l10n;
52
+        $this->text = $text;
53
+        $this->parameters = $parameters;
54
+        $this->count = $count;
55
+    }
56 56
 
57
-	/**
58
-	 * @return string
59
-	 */
60
-	public function __toString() {
61
-		$translations = $this->l10n->getTranslations();
57
+    /**
58
+     * @return string
59
+     */
60
+    public function __toString() {
61
+        $translations = $this->l10n->getTranslations();
62 62
 
63
-		$text = $this->text;
64
-		if(array_key_exists($this->text, $translations)) {
65
-			if(is_array($translations[$this->text])) {
66
-				$fn = $this->l10n->getPluralFormFunction();
67
-				$id = $fn($this->count);
68
-				$text = $translations[$this->text][$id];
69
-			}
70
-			else{
71
-				$text = $translations[$this->text];
72
-			}
73
-		}
63
+        $text = $this->text;
64
+        if(array_key_exists($this->text, $translations)) {
65
+            if(is_array($translations[$this->text])) {
66
+                $fn = $this->l10n->getPluralFormFunction();
67
+                $id = $fn($this->count);
68
+                $text = $translations[$this->text][$id];
69
+            }
70
+            else{
71
+                $text = $translations[$this->text];
72
+            }
73
+        }
74 74
 
75
-		// Replace %n first (won't interfere with vsprintf)
76
-		$text = str_replace('%n', (string)$this->count, $text);
77
-		return vsprintf($text, $this->parameters);
78
-	}
75
+        // Replace %n first (won't interfere with vsprintf)
76
+        $text = str_replace('%n', (string)$this->count, $text);
77
+        return vsprintf($text, $this->parameters);
78
+    }
79 79
 
80 80
 
81
-	/**
82
-	 * @return string
83
-	 */
84
-	public function jsonSerialize() {
85
-		return $this->__toString();
86
-	}
81
+    /**
82
+     * @return string
83
+     */
84
+    public function jsonSerialize() {
85
+        return $this->__toString();
86
+    }
87 87
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -56,19 +56,19 @@
 block discarded – undo
56 56
 		$translations = $this->l10n->getTranslations();
57 57
 
58 58
 		$text = $this->text;
59
-		if(array_key_exists($this->text, $translations)) {
60
-			if(is_array($translations[$this->text])) {
59
+		if (array_key_exists($this->text, $translations)) {
60
+			if (is_array($translations[$this->text])) {
61 61
 				$fn = $this->l10n->getPluralFormFunction();
62 62
 				$id = $fn($this->count);
63 63
 				$text = $translations[$this->text][$id];
64 64
 			}
65
-			else{
65
+			else {
66 66
 				$text = $translations[$this->text];
67 67
 			}
68 68
 		}
69 69
 
70 70
 		// Replace %n first (won't interfere with vsprintf)
71
-		$text = str_replace('%n', (string)$this->count, $text);
71
+		$text = str_replace('%n', (string) $this->count, $text);
72 72
 		return vsprintf($text, $this->parameters);
73 73
 	}
74 74
 
Please login to merge, or discard this patch.
lib/private/DB/QueryBuilder/ExpressionBuilder/OCIExpressionBuilder.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	public function castColumn($column, $type) {
148 148
 		if ($type === IQueryBuilder::PARAM_STR) {
149 149
 			$column = $this->helper->quoteColumnName($column);
150
-			return new QueryFunction('to_char(' . $column . ')');
150
+			return new QueryFunction('to_char('.$column.')');
151 151
 		}
152 152
 
153 153
 		return parent::castColumn($column, $type);
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 * @inheritdoc
158 158
 	 */
159 159
 	public function like($x, $y, $type = null) {
160
-		return parent::like($x, $y, $type) . " ESCAPE '\\'";
160
+		return parent::like($x, $y, $type)." ESCAPE '\\'";
161 161
 	}
162 162
 
163 163
 	/**
@@ -166,6 +166,6 @@  discard block
 block discarded – undo
166 166
 	public function iLike($x, $y, $type = null) {
167 167
 		$x = $this->helper->quoteColumnName($x);
168 168
 		$y = $this->helper->quoteColumnName($y);
169
-		return new QueryFunction('REGEXP_LIKE(' . $x . ', \'^\' || REPLACE(REPLACE(' . $y . ', \'%\', \'.*\'), \'_\', \'.\') || \'$\', \'i\')');
169
+		return new QueryFunction('REGEXP_LIKE('.$x.', \'^\' || REPLACE(REPLACE('.$y.', \'%\', \'.*\'), \'_\', \'.\') || \'$\', \'i\')');
170 170
 	}
171 171
 }
Please login to merge, or discard this patch.
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -33,161 +33,161 @@
 block discarded – undo
33 33
 
34 34
 class OCIExpressionBuilder extends ExpressionBuilder {
35 35
 
36
-	/**
37
-	 * @param mixed $column
38
-	 * @param mixed|null $type
39
-	 * @return array|IQueryFunction|string
40
-	 */
41
-	protected function prepareColumn($column, $type) {
42
-		if ($type === IQueryBuilder::PARAM_STR && !is_array($column) && !($column instanceof IParameter) && !($column instanceof ILiteral)) {
43
-			$column = $this->castColumn($column, $type);
44
-		} else {
45
-			$column = $this->helper->quoteColumnNames($column);
46
-		}
47
-		return $column;
48
-	}
49
-
50
-	/**
51
-	 * @inheritdoc
52
-	 */
53
-	public function comparison($x, $operator, $y, $type = null) {
54
-		$x = $this->prepareColumn($x, $type);
55
-		$y = $this->prepareColumn($y, $type);
56
-
57
-		return $this->expressionBuilder->comparison($x, $operator, $y);
58
-	}
59
-
60
-	/**
61
-	 * @inheritdoc
62
-	 */
63
-	public function eq($x, $y, $type = null) {
64
-		$x = $this->prepareColumn($x, $type);
65
-		$y = $this->prepareColumn($y, $type);
66
-
67
-		return $this->expressionBuilder->eq($x, $y);
68
-	}
69
-
70
-	/**
71
-	 * @inheritdoc
72
-	 */
73
-	public function neq($x, $y, $type = null) {
74
-		$x = $this->prepareColumn($x, $type);
75
-		$y = $this->prepareColumn($y, $type);
76
-
77
-		return $this->expressionBuilder->neq($x, $y);
78
-	}
79
-
80
-	/**
81
-	 * @inheritdoc
82
-	 */
83
-	public function lt($x, $y, $type = null) {
84
-		$x = $this->prepareColumn($x, $type);
85
-		$y = $this->prepareColumn($y, $type);
86
-
87
-		return $this->expressionBuilder->lt($x, $y);
88
-	}
89
-
90
-	/**
91
-	 * @inheritdoc
92
-	 */
93
-	public function lte($x, $y, $type = null) {
94
-		$x = $this->prepareColumn($x, $type);
95
-		$y = $this->prepareColumn($y, $type);
96
-
97
-		return $this->expressionBuilder->lte($x, $y);
98
-	}
99
-
100
-	/**
101
-	 * @inheritdoc
102
-	 */
103
-	public function gt($x, $y, $type = null) {
104
-		$x = $this->prepareColumn($x, $type);
105
-		$y = $this->prepareColumn($y, $type);
106
-
107
-		return $this->expressionBuilder->gt($x, $y);
108
-	}
109
-
110
-	/**
111
-	 * @inheritdoc
112
-	 */
113
-	public function gte($x, $y, $type = null) {
114
-		$x = $this->prepareColumn($x, $type);
115
-		$y = $this->prepareColumn($y, $type);
116
-
117
-		return $this->expressionBuilder->gte($x, $y);
118
-	}
119
-
120
-	/**
121
-	 * @inheritdoc
122
-	 */
123
-	public function in($x, $y, $type = null) {
124
-		$x = $this->prepareColumn($x, $type);
125
-		$y = $this->prepareColumn($y, $type);
126
-
127
-		return $this->expressionBuilder->in($x, $y);
128
-	}
129
-
130
-	/**
131
-	 * @inheritdoc
132
-	 */
133
-	public function notIn($x, $y, $type = null) {
134
-		$x = $this->prepareColumn($x, $type);
135
-		$y = $this->prepareColumn($y, $type);
136
-
137
-		return $this->expressionBuilder->notIn($x, $y);
138
-	}
139
-
140
-	/**
141
-	 * Creates a $x = '' statement, because Oracle needs a different check
142
-	 *
143
-	 * @param string $x The field in string format to be inspected by the comparison.
144
-	 * @return string
145
-	 * @since 13.0.0
146
-	 */
147
-	public function emptyString($x) {
148
-		return $this->isNull($x);
149
-	}
150
-
151
-	/**
152
-	 * Creates a `$x <> ''` statement, because Oracle needs a different check
153
-	 *
154
-	 * @param string $x The field in string format to be inspected by the comparison.
155
-	 * @return string
156
-	 * @since 13.0.0
157
-	 */
158
-	public function nonEmptyString($x) {
159
-		return $this->isNotNull($x);
160
-	}
161
-
162
-	/**
163
-	 * Returns a IQueryFunction that casts the column to the given type
164
-	 *
165
-	 * @param string $column
166
-	 * @param mixed $type One of IQueryBuilder::PARAM_*
167
-	 * @return IQueryFunction
168
-	 */
169
-	public function castColumn($column, $type) {
170
-		if ($type === IQueryBuilder::PARAM_STR) {
171
-			$column = $this->helper->quoteColumnName($column);
172
-			return new QueryFunction('to_char(' . $column . ')');
173
-		}
174
-
175
-		return parent::castColumn($column, $type);
176
-	}
177
-
178
-	/**
179
-	 * @inheritdoc
180
-	 */
181
-	public function like($x, $y, $type = null) {
182
-		return parent::like($x, $y, $type) . " ESCAPE '\\'";
183
-	}
184
-
185
-	/**
186
-	 * @inheritdoc
187
-	 */
188
-	public function iLike($x, $y, $type = null) {
189
-		$x = $this->helper->quoteColumnName($x);
190
-		$y = $this->helper->quoteColumnName($y);
191
-		return new QueryFunction('REGEXP_LIKE(' . $x . ', \'^\' || REPLACE(REPLACE(' . $y . ', \'%\', \'.*\'), \'_\', \'.\') || \'$\', \'i\')');
192
-	}
36
+    /**
37
+     * @param mixed $column
38
+     * @param mixed|null $type
39
+     * @return array|IQueryFunction|string
40
+     */
41
+    protected function prepareColumn($column, $type) {
42
+        if ($type === IQueryBuilder::PARAM_STR && !is_array($column) && !($column instanceof IParameter) && !($column instanceof ILiteral)) {
43
+            $column = $this->castColumn($column, $type);
44
+        } else {
45
+            $column = $this->helper->quoteColumnNames($column);
46
+        }
47
+        return $column;
48
+    }
49
+
50
+    /**
51
+     * @inheritdoc
52
+     */
53
+    public function comparison($x, $operator, $y, $type = null) {
54
+        $x = $this->prepareColumn($x, $type);
55
+        $y = $this->prepareColumn($y, $type);
56
+
57
+        return $this->expressionBuilder->comparison($x, $operator, $y);
58
+    }
59
+
60
+    /**
61
+     * @inheritdoc
62
+     */
63
+    public function eq($x, $y, $type = null) {
64
+        $x = $this->prepareColumn($x, $type);
65
+        $y = $this->prepareColumn($y, $type);
66
+
67
+        return $this->expressionBuilder->eq($x, $y);
68
+    }
69
+
70
+    /**
71
+     * @inheritdoc
72
+     */
73
+    public function neq($x, $y, $type = null) {
74
+        $x = $this->prepareColumn($x, $type);
75
+        $y = $this->prepareColumn($y, $type);
76
+
77
+        return $this->expressionBuilder->neq($x, $y);
78
+    }
79
+
80
+    /**
81
+     * @inheritdoc
82
+     */
83
+    public function lt($x, $y, $type = null) {
84
+        $x = $this->prepareColumn($x, $type);
85
+        $y = $this->prepareColumn($y, $type);
86
+
87
+        return $this->expressionBuilder->lt($x, $y);
88
+    }
89
+
90
+    /**
91
+     * @inheritdoc
92
+     */
93
+    public function lte($x, $y, $type = null) {
94
+        $x = $this->prepareColumn($x, $type);
95
+        $y = $this->prepareColumn($y, $type);
96
+
97
+        return $this->expressionBuilder->lte($x, $y);
98
+    }
99
+
100
+    /**
101
+     * @inheritdoc
102
+     */
103
+    public function gt($x, $y, $type = null) {
104
+        $x = $this->prepareColumn($x, $type);
105
+        $y = $this->prepareColumn($y, $type);
106
+
107
+        return $this->expressionBuilder->gt($x, $y);
108
+    }
109
+
110
+    /**
111
+     * @inheritdoc
112
+     */
113
+    public function gte($x, $y, $type = null) {
114
+        $x = $this->prepareColumn($x, $type);
115
+        $y = $this->prepareColumn($y, $type);
116
+
117
+        return $this->expressionBuilder->gte($x, $y);
118
+    }
119
+
120
+    /**
121
+     * @inheritdoc
122
+     */
123
+    public function in($x, $y, $type = null) {
124
+        $x = $this->prepareColumn($x, $type);
125
+        $y = $this->prepareColumn($y, $type);
126
+
127
+        return $this->expressionBuilder->in($x, $y);
128
+    }
129
+
130
+    /**
131
+     * @inheritdoc
132
+     */
133
+    public function notIn($x, $y, $type = null) {
134
+        $x = $this->prepareColumn($x, $type);
135
+        $y = $this->prepareColumn($y, $type);
136
+
137
+        return $this->expressionBuilder->notIn($x, $y);
138
+    }
139
+
140
+    /**
141
+     * Creates a $x = '' statement, because Oracle needs a different check
142
+     *
143
+     * @param string $x The field in string format to be inspected by the comparison.
144
+     * @return string
145
+     * @since 13.0.0
146
+     */
147
+    public function emptyString($x) {
148
+        return $this->isNull($x);
149
+    }
150
+
151
+    /**
152
+     * Creates a `$x <> ''` statement, because Oracle needs a different check
153
+     *
154
+     * @param string $x The field in string format to be inspected by the comparison.
155
+     * @return string
156
+     * @since 13.0.0
157
+     */
158
+    public function nonEmptyString($x) {
159
+        return $this->isNotNull($x);
160
+    }
161
+
162
+    /**
163
+     * Returns a IQueryFunction that casts the column to the given type
164
+     *
165
+     * @param string $column
166
+     * @param mixed $type One of IQueryBuilder::PARAM_*
167
+     * @return IQueryFunction
168
+     */
169
+    public function castColumn($column, $type) {
170
+        if ($type === IQueryBuilder::PARAM_STR) {
171
+            $column = $this->helper->quoteColumnName($column);
172
+            return new QueryFunction('to_char(' . $column . ')');
173
+        }
174
+
175
+        return parent::castColumn($column, $type);
176
+    }
177
+
178
+    /**
179
+     * @inheritdoc
180
+     */
181
+    public function like($x, $y, $type = null) {
182
+        return parent::like($x, $y, $type) . " ESCAPE '\\'";
183
+    }
184
+
185
+    /**
186
+     * @inheritdoc
187
+     */
188
+    public function iLike($x, $y, $type = null) {
189
+        $x = $this->helper->quoteColumnName($x);
190
+        $y = $this->helper->quoteColumnName($y);
191
+        return new QueryFunction('REGEXP_LIKE(' . $x . ', \'^\' || REPLACE(REPLACE(' . $y . ', \'%\', \'.*\'), \'_\', \'.\') || \'$\', \'i\')');
192
+    }
193 193
 }
Please login to merge, or discard this patch.
core/Command/Db/ConvertType.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
 		$schemaManager = new \OC\DB\MDB2SchemaManager($toDB);
235 235
 		$apps = $input->getOption('all-apps') ? \OC_App::getAllApps() : \OC_App::getEnabledApps();
236
-		foreach($apps as $app) {
236
+		foreach ($apps as $app) {
237 237
 			if (file_exists(\OC_App::getAppPath($app).'/appinfo/database.xml')) {
238 238
 				$schemaManager->createDbFromStructure(\OC_App::getAppPath($app).'/appinfo/database.xml');
239 239
 			} else {
@@ -269,13 +269,13 @@  discard block
 block discarded – undo
269 269
 		if (!empty($toTables)) {
270 270
 			$output->writeln('<info>Clearing schema in new database</info>');
271 271
 		}
272
-		foreach($toTables as $table) {
272
+		foreach ($toTables as $table) {
273 273
 			$db->getSchemaManager()->dropTable($table);
274 274
 		}
275 275
 	}
276 276
 
277 277
 	protected function getTables(Connection $db) {
278
-		$filterExpression = '/^' . preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')) . '/';
278
+		$filterExpression = '/^'.preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')).'/';
279 279
 		$db->getConfiguration()->
280 280
 			setFilterSchemaAssetsExpression($filterExpression);
281 281
 		return $db->getSchemaManager()->listTableNames();
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	 * @suppress SqlInjectionChecker
291 291
 	 */
292 292
 	protected function copyTable(Connection $fromDB, Connection $toDB, Table $table, InputInterface $input, OutputInterface $output) {
293
-		if ($table->getName() === $toDB->getPrefix() . 'migrations') {
293
+		if ($table->getName() === $toDB->getPrefix().'migrations') {
294 294
 			$output->writeln('<comment>Skipping migrations table because it was already filled by running the migrations</comment>');
295 295
 			return;
296 296
 		}
@@ -305,9 +305,9 @@  discard block
 block discarded – undo
305 305
 		$count = $result->fetchColumn();
306 306
 		$result->closeCursor();
307 307
 
308
-		$numChunks = ceil($count/$chunkSize);
308
+		$numChunks = ceil($count / $chunkSize);
309 309
 		if ($numChunks > 1) {
310
-			$output->writeln('chunked query, ' . $numChunks . ' chunks');
310
+			$output->writeln('chunked query, '.$numChunks.' chunks');
311 311
 		}
312 312
 
313 313
 		$progress = new ProgressBar($output, $count);
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 
395 395
 		try {
396 396
 			// copy table rows
397
-			foreach($tables as $table) {
397
+			foreach ($tables as $table) {
398 398
 				$output->writeln($table);
399 399
 				$this->copyTable($fromDB, $toDB, $schema->getTable($table), $input, $output);
400 400
 			}
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 			}
405 405
 			// save new database config
406 406
 			$this->saveDBInfo($input);
407
-		} catch(\Exception $e) {
407
+		} catch (\Exception $e) {
408 408
 			$this->config->setSystemValue('maintenance', false);
409 409
 			throw $e;
410 410
 		}
Please login to merge, or discard this patch.
Indentation   +410 added lines, -410 removed lines patch added patch discarded remove patch
@@ -52,414 +52,414 @@
 block discarded – undo
52 52
 use Symfony\Component\Console\Question\Question;
53 53
 
54 54
 class ConvertType extends Command implements CompletionAwareInterface {
55
-	/**
56
-	 * @var \OCP\IConfig
57
-	 */
58
-	protected $config;
59
-
60
-	/**
61
-	 * @var \OC\DB\ConnectionFactory
62
-	 */
63
-	protected $connectionFactory;
64
-
65
-	/** @var array */
66
-	protected $columnTypes;
67
-
68
-	/**
69
-	 * @param \OCP\IConfig $config
70
-	 * @param \OC\DB\ConnectionFactory $connectionFactory
71
-	 */
72
-	public function __construct(IConfig $config, ConnectionFactory $connectionFactory) {
73
-		$this->config = $config;
74
-		$this->connectionFactory = $connectionFactory;
75
-		parent::__construct();
76
-	}
77
-
78
-	protected function configure() {
79
-		$this
80
-			->setName('db:convert-type')
81
-			->setDescription('Convert the Nextcloud database to the newly configured one')
82
-			->addArgument(
83
-				'type',
84
-				InputArgument::REQUIRED,
85
-				'the type of the database to convert to'
86
-			)
87
-			->addArgument(
88
-				'username',
89
-				InputArgument::REQUIRED,
90
-				'the username of the database to convert to'
91
-			)
92
-			->addArgument(
93
-				'hostname',
94
-				InputArgument::REQUIRED,
95
-				'the hostname of the database to convert to'
96
-			)
97
-			->addArgument(
98
-				'database',
99
-				InputArgument::REQUIRED,
100
-				'the name of the database to convert to'
101
-			)
102
-			->addOption(
103
-				'port',
104
-				null,
105
-				InputOption::VALUE_REQUIRED,
106
-				'the port of the database to convert to'
107
-			)
108
-			->addOption(
109
-				'password',
110
-				null,
111
-				InputOption::VALUE_REQUIRED,
112
-				'the password of the database to convert to. Will be asked when not specified. Can also be passed via stdin.'
113
-			)
114
-			->addOption(
115
-				'clear-schema',
116
-				null,
117
-				InputOption::VALUE_NONE,
118
-				'remove all tables from the destination database'
119
-			)
120
-			->addOption(
121
-				'all-apps',
122
-				null,
123
-				InputOption::VALUE_NONE,
124
-				'whether to create schema for all apps instead of only installed apps'
125
-			)
126
-			->addOption(
127
-				'chunk-size',
128
-				null,
129
-				InputOption::VALUE_REQUIRED,
130
-				'the maximum number of database rows to handle in a single query, bigger tables will be handled in chunks of this size. Lower this if the process runs out of memory during conversion.',
131
-				1000
132
-			)
133
-		;
134
-	}
135
-
136
-	protected function validateInput(InputInterface $input, OutputInterface $output) {
137
-		$type = $this->connectionFactory->normalizeType($input->getArgument('type'));
138
-		if ($type === 'sqlite3') {
139
-			throw new \InvalidArgumentException(
140
-				'Converting to SQLite (sqlite3) is currently not supported.'
141
-			);
142
-		}
143
-		if ($type === $this->config->getSystemValue('dbtype', '')) {
144
-			throw new \InvalidArgumentException(sprintf(
145
-				'Can not convert from %1$s to %1$s.',
146
-				$type
147
-			));
148
-		}
149
-		if ($type === 'oci' && $input->getOption('clear-schema')) {
150
-			// Doctrine unconditionally tries (at least in version 2.3)
151
-			// to drop sequence triggers when dropping a table, even though
152
-			// such triggers may not exist. This results in errors like
153
-			// "ORA-04080: trigger 'OC_STORAGES_AI_PK' does not exist".
154
-			throw new \InvalidArgumentException(
155
-				'The --clear-schema option is not supported when converting to Oracle (oci).'
156
-			);
157
-		}
158
-	}
159
-
160
-	protected function readPassword(InputInterface $input, OutputInterface $output) {
161
-		// Explicitly specified password
162
-		if ($input->getOption('password')) {
163
-			return;
164
-		}
165
-
166
-		// Read from stdin. stream_set_blocking is used to prevent blocking
167
-		// when nothing is passed via stdin.
168
-		stream_set_blocking(STDIN, 0);
169
-		$password = file_get_contents('php://stdin');
170
-		stream_set_blocking(STDIN, 1);
171
-		if (trim($password) !== '') {
172
-			$input->setOption('password', $password);
173
-			return;
174
-		}
175
-
176
-		// Read password by interacting
177
-		if ($input->isInteractive()) {
178
-			/** @var QuestionHelper $helper */
179
-			$helper = $this->getHelper('question');
180
-			$question = new Question('What is the database password?');
181
-			$question->setHidden(true);
182
-			$question->setHiddenFallback(false);
183
-			$password = $helper->ask($input, $output, $question);
184
-			$input->setOption('password', $password);
185
-			return;
186
-		}
187
-	}
188
-
189
-	protected function execute(InputInterface $input, OutputInterface $output) {
190
-		$this->validateInput($input, $output);
191
-		$this->readPassword($input, $output);
192
-
193
-		$fromDB = \OC::$server->getDatabaseConnection();
194
-		$toDB = $this->getToDBConnection($input, $output);
195
-
196
-		if ($input->getOption('clear-schema')) {
197
-			$this->clearSchema($toDB, $input, $output);
198
-		}
199
-
200
-		$this->createSchema($fromDB, $toDB, $input, $output);
201
-
202
-		$toTables = $this->getTables($toDB);
203
-		$fromTables = $this->getTables($fromDB);
204
-
205
-		// warn/fail if there are more tables in 'from' database
206
-		$extraFromTables = array_diff($fromTables, $toTables);
207
-		if (!empty($extraFromTables)) {
208
-			$output->writeln('<comment>The following tables will not be converted:</comment>');
209
-			$output->writeln($extraFromTables);
210
-			if (!$input->getOption('all-apps')) {
211
-				$output->writeln('<comment>Please note that tables belonging to available but currently not installed apps</comment>');
212
-				$output->writeln('<comment>can be included by specifying the --all-apps option.</comment>');
213
-			}
214
-
215
-			$continueConversion = !$input->isInteractive(); // assume yes for --no-interaction and no otherwise.
216
-			$question = new ConfirmationQuestion('Continue with the conversion (y/n)? [n] ', $continueConversion);
217
-
218
-			/** @var QuestionHelper $helper */
219
-			$helper = $this->getHelper('question');
220
-
221
-			if (!$helper->ask($input, $output, $question)) {
222
-				return;
223
-			}
224
-		}
225
-		$intersectingTables = array_intersect($toTables, $fromTables);
226
-		$this->convertDB($fromDB, $toDB, $intersectingTables, $input, $output);
227
-	}
228
-
229
-	protected function createSchema(Connection $fromDB, Connection $toDB, InputInterface $input, OutputInterface $output) {
230
-		$output->writeln('<info>Creating schema in new database</info>');
231
-
232
-		$fromMS = new MigrationService('core', $fromDB);
233
-		$currentMigration = $fromMS->getMigration('current');
234
-		if ($currentMigration !== '0') {
235
-			$toMS = new MigrationService('core', $toDB);
236
-			$toMS->migrate($currentMigration);
237
-		}
238
-
239
-		$schemaManager = new \OC\DB\MDB2SchemaManager($toDB);
240
-		$apps = $input->getOption('all-apps') ? \OC_App::getAllApps() : \OC_App::getEnabledApps();
241
-		foreach($apps as $app) {
242
-			if (file_exists(\OC_App::getAppPath($app).'/appinfo/database.xml')) {
243
-				$schemaManager->createDbFromStructure(\OC_App::getAppPath($app).'/appinfo/database.xml');
244
-			} else {
245
-				// Make sure autoloading works...
246
-				\OC_App::loadApp($app);
247
-				$fromMS = new MigrationService($app, $fromDB);
248
-				$currentMigration = $fromMS->getMigration('current');
249
-				if ($currentMigration !== '0') {
250
-					$toMS = new MigrationService($app, $toDB);
251
-					$toMS->migrate($currentMigration, true);
252
-				}
253
-			}
254
-		}
255
-	}
256
-
257
-	protected function getToDBConnection(InputInterface $input, OutputInterface $output) {
258
-		$type = $input->getArgument('type');
259
-		$connectionParams = $this->connectionFactory->createConnectionParams();
260
-		$connectionParams = array_merge($connectionParams, [
261
-			'host' => $input->getArgument('hostname'),
262
-			'user' => $input->getArgument('username'),
263
-			'password' => $input->getOption('password'),
264
-			'dbname' => $input->getArgument('database'),
265
-		]);
266
-		if ($input->getOption('port')) {
267
-			$connectionParams['port'] = $input->getOption('port');
268
-		}
269
-		return $this->connectionFactory->getConnection($type, $connectionParams);
270
-	}
271
-
272
-	protected function clearSchema(Connection $db, InputInterface $input, OutputInterface $output) {
273
-		$toTables = $this->getTables($db);
274
-		if (!empty($toTables)) {
275
-			$output->writeln('<info>Clearing schema in new database</info>');
276
-		}
277
-		foreach($toTables as $table) {
278
-			$db->getSchemaManager()->dropTable($table);
279
-		}
280
-	}
281
-
282
-	protected function getTables(Connection $db) {
283
-		$filterExpression = '/^' . preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')) . '/';
284
-		$db->getConfiguration()->
285
-			setFilterSchemaAssetsExpression($filterExpression);
286
-		return $db->getSchemaManager()->listTableNames();
287
-	}
288
-
289
-	/**
290
-	 * @param Connection $fromDB
291
-	 * @param Connection $toDB
292
-	 * @param Table $table
293
-	 * @param InputInterface $input
294
-	 * @param OutputInterface $output
295
-	 * @suppress SqlInjectionChecker
296
-	 */
297
-	protected function copyTable(Connection $fromDB, Connection $toDB, Table $table, InputInterface $input, OutputInterface $output) {
298
-		if ($table->getName() === $toDB->getPrefix() . 'migrations') {
299
-			$output->writeln('<comment>Skipping migrations table because it was already filled by running the migrations</comment>');
300
-			return;
301
-		}
302
-
303
-		$chunkSize = $input->getOption('chunk-size');
304
-
305
-		$query = $fromDB->getQueryBuilder();
306
-		$query->automaticTablePrefix(false);
307
-		$query->select($query->func()->count('*', 'num_entries'))
308
-			->from($table->getName());
309
-		$result = $query->execute();
310
-		$count = $result->fetchColumn();
311
-		$result->closeCursor();
312
-
313
-		$numChunks = ceil($count/$chunkSize);
314
-		if ($numChunks > 1) {
315
-			$output->writeln('chunked query, ' . $numChunks . ' chunks');
316
-		}
317
-
318
-		$progress = new ProgressBar($output, $count);
319
-		$progress->start();
320
-		$redraw = $count > $chunkSize ? 100 : ($count > 100 ? 5 : 1);
321
-		$progress->setRedrawFrequency($redraw);
322
-
323
-		$query = $fromDB->getQueryBuilder();
324
-		$query->automaticTablePrefix(false);
325
-		$query->select('*')
326
-			->from($table->getName())
327
-			->setMaxResults($chunkSize);
328
-
329
-		try {
330
-			$orderColumns = $table->getPrimaryKeyColumns();
331
-		} catch (DBALException $e) {
332
-			$orderColumns = [];
333
-			foreach ($table->getColumns() as $column) {
334
-				$orderColumns[] = $column->getName();
335
-			}
336
-		}
337
-
338
-		foreach ($orderColumns as $column) {
339
-			$query->addOrderBy($column);
340
-		}
341
-
342
-		$insertQuery = $toDB->getQueryBuilder();
343
-		$insertQuery->automaticTablePrefix(false);
344
-		$insertQuery->insert($table->getName());
345
-		$parametersCreated = false;
346
-
347
-		for ($chunk = 0; $chunk < $numChunks; $chunk++) {
348
-			$query->setFirstResult($chunk * $chunkSize);
349
-
350
-			$result = $query->execute();
351
-
352
-			while ($row = $result->fetch()) {
353
-				$progress->advance();
354
-				if (!$parametersCreated) {
355
-					foreach ($row as $key => $value) {
356
-						$insertQuery->setValue($key, $insertQuery->createParameter($key));
357
-					}
358
-					$parametersCreated = true;
359
-				}
360
-
361
-				foreach ($row as $key => $value) {
362
-					$type = $this->getColumnType($table, $key);
363
-					if ($type !== false) {
364
-						$insertQuery->setParameter($key, $value, $type);
365
-					} else {
366
-						$insertQuery->setParameter($key, $value);
367
-					}
368
-				}
369
-				$insertQuery->execute();
370
-			}
371
-			$result->closeCursor();
372
-		}
373
-		$progress->finish();
374
-	}
375
-
376
-	protected function getColumnType(Table $table, $columnName) {
377
-		$tableName = $table->getName();
378
-		if (isset($this->columnTypes[$tableName][$columnName])) {
379
-			return $this->columnTypes[$tableName][$columnName];
380
-		}
381
-
382
-		$type = $table->getColumn($columnName)->getType()->getName();
383
-
384
-		switch ($type) {
385
-			case Type::BLOB:
386
-			case Type::TEXT:
387
-				$this->columnTypes[$tableName][$columnName] = IQueryBuilder::PARAM_LOB;
388
-				break;
389
-			case Type::BOOLEAN:
390
-				$this->columnTypes[$tableName][$columnName] = IQueryBuilder::PARAM_BOOL;
391
-				break;
392
-			default:
393
-				$this->columnTypes[$tableName][$columnName] = false;
394
-		}
395
-
396
-		return $this->columnTypes[$tableName][$columnName];
397
-	}
398
-
399
-	protected function convertDB(Connection $fromDB, Connection $toDB, array $tables, InputInterface $input, OutputInterface $output) {
400
-		$this->config->setSystemValue('maintenance', true);
401
-		$schema = $fromDB->createSchema();
402
-
403
-		try {
404
-			// copy table rows
405
-			foreach($tables as $table) {
406
-				$output->writeln($table);
407
-				$this->copyTable($fromDB, $toDB, $schema->getTable($table), $input, $output);
408
-			}
409
-			if ($input->getArgument('type') === 'pgsql') {
410
-				$tools = new \OC\DB\PgSqlTools($this->config);
411
-				$tools->resynchronizeDatabaseSequences($toDB);
412
-			}
413
-			// save new database config
414
-			$this->saveDBInfo($input);
415
-		} catch(\Exception $e) {
416
-			$this->config->setSystemValue('maintenance', false);
417
-			throw $e;
418
-		}
419
-		$this->config->setSystemValue('maintenance', false);
420
-	}
421
-
422
-	protected function saveDBInfo(InputInterface $input) {
423
-		$type = $input->getArgument('type');
424
-		$username = $input->getArgument('username');
425
-		$dbHost = $input->getArgument('hostname');
426
-		$dbName = $input->getArgument('database');
427
-		$password = $input->getOption('password');
428
-		if ($input->getOption('port')) {
429
-			$dbHost .= ':'.$input->getOption('port');
430
-		}
431
-
432
-		$this->config->setSystemValues([
433
-			'dbtype'		=> $type,
434
-			'dbname'		=> $dbName,
435
-			'dbhost'		=> $dbHost,
436
-			'dbuser'		=> $username,
437
-			'dbpassword'	=> $password,
438
-		]);
439
-	}
440
-
441
-	/**
442
-	 * Return possible values for the named option
443
-	 *
444
-	 * @param string $optionName
445
-	 * @param CompletionContext $context
446
-	 * @return string[]
447
-	 */
448
-	public function completeOptionValues($optionName, CompletionContext $context) {
449
-		return [];
450
-	}
451
-
452
-	/**
453
-	 * Return possible values for the named argument
454
-	 *
455
-	 * @param string $argumentName
456
-	 * @param CompletionContext $context
457
-	 * @return string[]
458
-	 */
459
-	public function completeArgumentValues($argumentName, CompletionContext $context) {
460
-		if ($argumentName === 'type') {
461
-			return ['mysql', 'oci', 'pgsql'];
462
-		}
463
-		return [];
464
-	}
55
+    /**
56
+     * @var \OCP\IConfig
57
+     */
58
+    protected $config;
59
+
60
+    /**
61
+     * @var \OC\DB\ConnectionFactory
62
+     */
63
+    protected $connectionFactory;
64
+
65
+    /** @var array */
66
+    protected $columnTypes;
67
+
68
+    /**
69
+     * @param \OCP\IConfig $config
70
+     * @param \OC\DB\ConnectionFactory $connectionFactory
71
+     */
72
+    public function __construct(IConfig $config, ConnectionFactory $connectionFactory) {
73
+        $this->config = $config;
74
+        $this->connectionFactory = $connectionFactory;
75
+        parent::__construct();
76
+    }
77
+
78
+    protected function configure() {
79
+        $this
80
+            ->setName('db:convert-type')
81
+            ->setDescription('Convert the Nextcloud database to the newly configured one')
82
+            ->addArgument(
83
+                'type',
84
+                InputArgument::REQUIRED,
85
+                'the type of the database to convert to'
86
+            )
87
+            ->addArgument(
88
+                'username',
89
+                InputArgument::REQUIRED,
90
+                'the username of the database to convert to'
91
+            )
92
+            ->addArgument(
93
+                'hostname',
94
+                InputArgument::REQUIRED,
95
+                'the hostname of the database to convert to'
96
+            )
97
+            ->addArgument(
98
+                'database',
99
+                InputArgument::REQUIRED,
100
+                'the name of the database to convert to'
101
+            )
102
+            ->addOption(
103
+                'port',
104
+                null,
105
+                InputOption::VALUE_REQUIRED,
106
+                'the port of the database to convert to'
107
+            )
108
+            ->addOption(
109
+                'password',
110
+                null,
111
+                InputOption::VALUE_REQUIRED,
112
+                'the password of the database to convert to. Will be asked when not specified. Can also be passed via stdin.'
113
+            )
114
+            ->addOption(
115
+                'clear-schema',
116
+                null,
117
+                InputOption::VALUE_NONE,
118
+                'remove all tables from the destination database'
119
+            )
120
+            ->addOption(
121
+                'all-apps',
122
+                null,
123
+                InputOption::VALUE_NONE,
124
+                'whether to create schema for all apps instead of only installed apps'
125
+            )
126
+            ->addOption(
127
+                'chunk-size',
128
+                null,
129
+                InputOption::VALUE_REQUIRED,
130
+                'the maximum number of database rows to handle in a single query, bigger tables will be handled in chunks of this size. Lower this if the process runs out of memory during conversion.',
131
+                1000
132
+            )
133
+        ;
134
+    }
135
+
136
+    protected function validateInput(InputInterface $input, OutputInterface $output) {
137
+        $type = $this->connectionFactory->normalizeType($input->getArgument('type'));
138
+        if ($type === 'sqlite3') {
139
+            throw new \InvalidArgumentException(
140
+                'Converting to SQLite (sqlite3) is currently not supported.'
141
+            );
142
+        }
143
+        if ($type === $this->config->getSystemValue('dbtype', '')) {
144
+            throw new \InvalidArgumentException(sprintf(
145
+                'Can not convert from %1$s to %1$s.',
146
+                $type
147
+            ));
148
+        }
149
+        if ($type === 'oci' && $input->getOption('clear-schema')) {
150
+            // Doctrine unconditionally tries (at least in version 2.3)
151
+            // to drop sequence triggers when dropping a table, even though
152
+            // such triggers may not exist. This results in errors like
153
+            // "ORA-04080: trigger 'OC_STORAGES_AI_PK' does not exist".
154
+            throw new \InvalidArgumentException(
155
+                'The --clear-schema option is not supported when converting to Oracle (oci).'
156
+            );
157
+        }
158
+    }
159
+
160
+    protected function readPassword(InputInterface $input, OutputInterface $output) {
161
+        // Explicitly specified password
162
+        if ($input->getOption('password')) {
163
+            return;
164
+        }
165
+
166
+        // Read from stdin. stream_set_blocking is used to prevent blocking
167
+        // when nothing is passed via stdin.
168
+        stream_set_blocking(STDIN, 0);
169
+        $password = file_get_contents('php://stdin');
170
+        stream_set_blocking(STDIN, 1);
171
+        if (trim($password) !== '') {
172
+            $input->setOption('password', $password);
173
+            return;
174
+        }
175
+
176
+        // Read password by interacting
177
+        if ($input->isInteractive()) {
178
+            /** @var QuestionHelper $helper */
179
+            $helper = $this->getHelper('question');
180
+            $question = new Question('What is the database password?');
181
+            $question->setHidden(true);
182
+            $question->setHiddenFallback(false);
183
+            $password = $helper->ask($input, $output, $question);
184
+            $input->setOption('password', $password);
185
+            return;
186
+        }
187
+    }
188
+
189
+    protected function execute(InputInterface $input, OutputInterface $output) {
190
+        $this->validateInput($input, $output);
191
+        $this->readPassword($input, $output);
192
+
193
+        $fromDB = \OC::$server->getDatabaseConnection();
194
+        $toDB = $this->getToDBConnection($input, $output);
195
+
196
+        if ($input->getOption('clear-schema')) {
197
+            $this->clearSchema($toDB, $input, $output);
198
+        }
199
+
200
+        $this->createSchema($fromDB, $toDB, $input, $output);
201
+
202
+        $toTables = $this->getTables($toDB);
203
+        $fromTables = $this->getTables($fromDB);
204
+
205
+        // warn/fail if there are more tables in 'from' database
206
+        $extraFromTables = array_diff($fromTables, $toTables);
207
+        if (!empty($extraFromTables)) {
208
+            $output->writeln('<comment>The following tables will not be converted:</comment>');
209
+            $output->writeln($extraFromTables);
210
+            if (!$input->getOption('all-apps')) {
211
+                $output->writeln('<comment>Please note that tables belonging to available but currently not installed apps</comment>');
212
+                $output->writeln('<comment>can be included by specifying the --all-apps option.</comment>');
213
+            }
214
+
215
+            $continueConversion = !$input->isInteractive(); // assume yes for --no-interaction and no otherwise.
216
+            $question = new ConfirmationQuestion('Continue with the conversion (y/n)? [n] ', $continueConversion);
217
+
218
+            /** @var QuestionHelper $helper */
219
+            $helper = $this->getHelper('question');
220
+
221
+            if (!$helper->ask($input, $output, $question)) {
222
+                return;
223
+            }
224
+        }
225
+        $intersectingTables = array_intersect($toTables, $fromTables);
226
+        $this->convertDB($fromDB, $toDB, $intersectingTables, $input, $output);
227
+    }
228
+
229
+    protected function createSchema(Connection $fromDB, Connection $toDB, InputInterface $input, OutputInterface $output) {
230
+        $output->writeln('<info>Creating schema in new database</info>');
231
+
232
+        $fromMS = new MigrationService('core', $fromDB);
233
+        $currentMigration = $fromMS->getMigration('current');
234
+        if ($currentMigration !== '0') {
235
+            $toMS = new MigrationService('core', $toDB);
236
+            $toMS->migrate($currentMigration);
237
+        }
238
+
239
+        $schemaManager = new \OC\DB\MDB2SchemaManager($toDB);
240
+        $apps = $input->getOption('all-apps') ? \OC_App::getAllApps() : \OC_App::getEnabledApps();
241
+        foreach($apps as $app) {
242
+            if (file_exists(\OC_App::getAppPath($app).'/appinfo/database.xml')) {
243
+                $schemaManager->createDbFromStructure(\OC_App::getAppPath($app).'/appinfo/database.xml');
244
+            } else {
245
+                // Make sure autoloading works...
246
+                \OC_App::loadApp($app);
247
+                $fromMS = new MigrationService($app, $fromDB);
248
+                $currentMigration = $fromMS->getMigration('current');
249
+                if ($currentMigration !== '0') {
250
+                    $toMS = new MigrationService($app, $toDB);
251
+                    $toMS->migrate($currentMigration, true);
252
+                }
253
+            }
254
+        }
255
+    }
256
+
257
+    protected function getToDBConnection(InputInterface $input, OutputInterface $output) {
258
+        $type = $input->getArgument('type');
259
+        $connectionParams = $this->connectionFactory->createConnectionParams();
260
+        $connectionParams = array_merge($connectionParams, [
261
+            'host' => $input->getArgument('hostname'),
262
+            'user' => $input->getArgument('username'),
263
+            'password' => $input->getOption('password'),
264
+            'dbname' => $input->getArgument('database'),
265
+        ]);
266
+        if ($input->getOption('port')) {
267
+            $connectionParams['port'] = $input->getOption('port');
268
+        }
269
+        return $this->connectionFactory->getConnection($type, $connectionParams);
270
+    }
271
+
272
+    protected function clearSchema(Connection $db, InputInterface $input, OutputInterface $output) {
273
+        $toTables = $this->getTables($db);
274
+        if (!empty($toTables)) {
275
+            $output->writeln('<info>Clearing schema in new database</info>');
276
+        }
277
+        foreach($toTables as $table) {
278
+            $db->getSchemaManager()->dropTable($table);
279
+        }
280
+    }
281
+
282
+    protected function getTables(Connection $db) {
283
+        $filterExpression = '/^' . preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')) . '/';
284
+        $db->getConfiguration()->
285
+            setFilterSchemaAssetsExpression($filterExpression);
286
+        return $db->getSchemaManager()->listTableNames();
287
+    }
288
+
289
+    /**
290
+     * @param Connection $fromDB
291
+     * @param Connection $toDB
292
+     * @param Table $table
293
+     * @param InputInterface $input
294
+     * @param OutputInterface $output
295
+     * @suppress SqlInjectionChecker
296
+     */
297
+    protected function copyTable(Connection $fromDB, Connection $toDB, Table $table, InputInterface $input, OutputInterface $output) {
298
+        if ($table->getName() === $toDB->getPrefix() . 'migrations') {
299
+            $output->writeln('<comment>Skipping migrations table because it was already filled by running the migrations</comment>');
300
+            return;
301
+        }
302
+
303
+        $chunkSize = $input->getOption('chunk-size');
304
+
305
+        $query = $fromDB->getQueryBuilder();
306
+        $query->automaticTablePrefix(false);
307
+        $query->select($query->func()->count('*', 'num_entries'))
308
+            ->from($table->getName());
309
+        $result = $query->execute();
310
+        $count = $result->fetchColumn();
311
+        $result->closeCursor();
312
+
313
+        $numChunks = ceil($count/$chunkSize);
314
+        if ($numChunks > 1) {
315
+            $output->writeln('chunked query, ' . $numChunks . ' chunks');
316
+        }
317
+
318
+        $progress = new ProgressBar($output, $count);
319
+        $progress->start();
320
+        $redraw = $count > $chunkSize ? 100 : ($count > 100 ? 5 : 1);
321
+        $progress->setRedrawFrequency($redraw);
322
+
323
+        $query = $fromDB->getQueryBuilder();
324
+        $query->automaticTablePrefix(false);
325
+        $query->select('*')
326
+            ->from($table->getName())
327
+            ->setMaxResults($chunkSize);
328
+
329
+        try {
330
+            $orderColumns = $table->getPrimaryKeyColumns();
331
+        } catch (DBALException $e) {
332
+            $orderColumns = [];
333
+            foreach ($table->getColumns() as $column) {
334
+                $orderColumns[] = $column->getName();
335
+            }
336
+        }
337
+
338
+        foreach ($orderColumns as $column) {
339
+            $query->addOrderBy($column);
340
+        }
341
+
342
+        $insertQuery = $toDB->getQueryBuilder();
343
+        $insertQuery->automaticTablePrefix(false);
344
+        $insertQuery->insert($table->getName());
345
+        $parametersCreated = false;
346
+
347
+        for ($chunk = 0; $chunk < $numChunks; $chunk++) {
348
+            $query->setFirstResult($chunk * $chunkSize);
349
+
350
+            $result = $query->execute();
351
+
352
+            while ($row = $result->fetch()) {
353
+                $progress->advance();
354
+                if (!$parametersCreated) {
355
+                    foreach ($row as $key => $value) {
356
+                        $insertQuery->setValue($key, $insertQuery->createParameter($key));
357
+                    }
358
+                    $parametersCreated = true;
359
+                }
360
+
361
+                foreach ($row as $key => $value) {
362
+                    $type = $this->getColumnType($table, $key);
363
+                    if ($type !== false) {
364
+                        $insertQuery->setParameter($key, $value, $type);
365
+                    } else {
366
+                        $insertQuery->setParameter($key, $value);
367
+                    }
368
+                }
369
+                $insertQuery->execute();
370
+            }
371
+            $result->closeCursor();
372
+        }
373
+        $progress->finish();
374
+    }
375
+
376
+    protected function getColumnType(Table $table, $columnName) {
377
+        $tableName = $table->getName();
378
+        if (isset($this->columnTypes[$tableName][$columnName])) {
379
+            return $this->columnTypes[$tableName][$columnName];
380
+        }
381
+
382
+        $type = $table->getColumn($columnName)->getType()->getName();
383
+
384
+        switch ($type) {
385
+            case Type::BLOB:
386
+            case Type::TEXT:
387
+                $this->columnTypes[$tableName][$columnName] = IQueryBuilder::PARAM_LOB;
388
+                break;
389
+            case Type::BOOLEAN:
390
+                $this->columnTypes[$tableName][$columnName] = IQueryBuilder::PARAM_BOOL;
391
+                break;
392
+            default:
393
+                $this->columnTypes[$tableName][$columnName] = false;
394
+        }
395
+
396
+        return $this->columnTypes[$tableName][$columnName];
397
+    }
398
+
399
+    protected function convertDB(Connection $fromDB, Connection $toDB, array $tables, InputInterface $input, OutputInterface $output) {
400
+        $this->config->setSystemValue('maintenance', true);
401
+        $schema = $fromDB->createSchema();
402
+
403
+        try {
404
+            // copy table rows
405
+            foreach($tables as $table) {
406
+                $output->writeln($table);
407
+                $this->copyTable($fromDB, $toDB, $schema->getTable($table), $input, $output);
408
+            }
409
+            if ($input->getArgument('type') === 'pgsql') {
410
+                $tools = new \OC\DB\PgSqlTools($this->config);
411
+                $tools->resynchronizeDatabaseSequences($toDB);
412
+            }
413
+            // save new database config
414
+            $this->saveDBInfo($input);
415
+        } catch(\Exception $e) {
416
+            $this->config->setSystemValue('maintenance', false);
417
+            throw $e;
418
+        }
419
+        $this->config->setSystemValue('maintenance', false);
420
+    }
421
+
422
+    protected function saveDBInfo(InputInterface $input) {
423
+        $type = $input->getArgument('type');
424
+        $username = $input->getArgument('username');
425
+        $dbHost = $input->getArgument('hostname');
426
+        $dbName = $input->getArgument('database');
427
+        $password = $input->getOption('password');
428
+        if ($input->getOption('port')) {
429
+            $dbHost .= ':'.$input->getOption('port');
430
+        }
431
+
432
+        $this->config->setSystemValues([
433
+            'dbtype'		=> $type,
434
+            'dbname'		=> $dbName,
435
+            'dbhost'		=> $dbHost,
436
+            'dbuser'		=> $username,
437
+            'dbpassword'	=> $password,
438
+        ]);
439
+    }
440
+
441
+    /**
442
+     * Return possible values for the named option
443
+     *
444
+     * @param string $optionName
445
+     * @param CompletionContext $context
446
+     * @return string[]
447
+     */
448
+    public function completeOptionValues($optionName, CompletionContext $context) {
449
+        return [];
450
+    }
451
+
452
+    /**
453
+     * Return possible values for the named argument
454
+     *
455
+     * @param string $argumentName
456
+     * @param CompletionContext $context
457
+     * @return string[]
458
+     */
459
+    public function completeArgumentValues($argumentName, CompletionContext $context) {
460
+        if ($argumentName === 'type') {
461
+            return ['mysql', 'oci', 'pgsql'];
462
+        }
463
+        return [];
464
+    }
465 465
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Controller/GlobalStoragesController.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -197,7 +197,7 @@
 block discarded – undo
197 197
 		} catch (NotFoundException $e) {
198 198
 			return new DataResponse(
199 199
 				[
200
-					'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id])
200
+					'message' => (string) $this->l10n->t('Storage with ID "%d" not found', [$id])
201 201
 				],
202 202
 				Http::STATUS_NOT_FOUND
203 203
 			);
Please login to merge, or discard this patch.
Indentation   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -40,151 +40,151 @@
 block discarded – undo
40 40
  * Global storages controller
41 41
  */
42 42
 class GlobalStoragesController extends StoragesController {
43
-	/**
44
-	 * Creates a new global storages controller.
45
-	 *
46
-	 * @param string $AppName application name
47
-	 * @param IRequest $request request object
48
-	 * @param IL10N $l10n l10n service
49
-	 * @param GlobalStoragesService $globalStoragesService storage service
50
-	 * @param ILogger $logger
51
-	 */
52
-	public function __construct(
53
-		$AppName,
54
-		IRequest $request,
55
-		IL10N $l10n,
56
-		GlobalStoragesService $globalStoragesService,
57
-		ILogger $logger
58
-	) {
59
-		parent::__construct(
60
-			$AppName,
61
-			$request,
62
-			$l10n,
63
-			$globalStoragesService,
64
-			$logger
65
-		);
66
-	}
67
-
68
-	/**
69
-	 * Create an external storage entry.
70
-	 *
71
-	 * @param string $mountPoint storage mount point
72
-	 * @param string $backend backend identifier
73
-	 * @param string $authMechanism authentication mechanism identifier
74
-	 * @param array $backendOptions backend-specific options
75
-	 * @param array $mountOptions mount-specific options
76
-	 * @param array $applicableUsers users for which to mount the storage
77
-	 * @param array $applicableGroups groups for which to mount the storage
78
-	 * @param int $priority priority
79
-	 *
80
-	 * @return DataResponse
81
-	 */
82
-	public function create(
83
-		$mountPoint,
84
-		$backend,
85
-		$authMechanism,
86
-		$backendOptions,
87
-		$mountOptions,
88
-		$applicableUsers,
89
-		$applicableGroups,
90
-		$priority
91
-	) {
92
-		$newStorage = $this->createStorage(
93
-			$mountPoint,
94
-			$backend,
95
-			$authMechanism,
96
-			$backendOptions,
97
-			$mountOptions,
98
-			$applicableUsers,
99
-			$applicableGroups,
100
-			$priority
101
-		);
102
-		if ($newStorage instanceof DataResponse) {
103
-			return $newStorage;
104
-		}
105
-
106
-		$response = $this->validate($newStorage);
107
-		if (!empty($response)) {
108
-			return $response;
109
-		}
110
-
111
-		$newStorage = $this->service->addStorage($newStorage);
112
-
113
-		$this->updateStorageStatus($newStorage);
114
-
115
-		return new DataResponse(
116
-			$this->formatStorageForUI($newStorage),
117
-			Http::STATUS_CREATED
118
-		);
119
-	}
120
-
121
-	/**
122
-	 * Update an external storage entry.
123
-	 *
124
-	 * @param int $id storage id
125
-	 * @param string $mountPoint storage mount point
126
-	 * @param string $backend backend identifier
127
-	 * @param string $authMechanism authentication mechansim identifier
128
-	 * @param array $backendOptions backend-specific options
129
-	 * @param array $mountOptions mount-specific options
130
-	 * @param array $applicableUsers users for which to mount the storage
131
-	 * @param array $applicableGroups groups for which to mount the storage
132
-	 * @param int $priority priority
133
-	 * @param bool $testOnly whether to storage should only test the connection or do more things
134
-	 *
135
-	 * @return DataResponse
136
-	 */
137
-	public function update(
138
-		$id,
139
-		$mountPoint,
140
-		$backend,
141
-		$authMechanism,
142
-		$backendOptions,
143
-		$mountOptions,
144
-		$applicableUsers,
145
-		$applicableGroups,
146
-		$priority,
147
-		$testOnly = true
148
-	) {
149
-		$storage = $this->createStorage(
150
-			$mountPoint,
151
-			$backend,
152
-			$authMechanism,
153
-			$backendOptions,
154
-			$mountOptions,
155
-			$applicableUsers,
156
-			$applicableGroups,
157
-			$priority
158
-		);
159
-		if ($storage instanceof DataResponse) {
160
-			return $storage;
161
-		}
162
-		$storage->setId($id);
163
-
164
-		$response = $this->validate($storage);
165
-		if (!empty($response)) {
166
-			return $response;
167
-		}
168
-
169
-		try {
170
-			$storage = $this->service->updateStorage($storage);
171
-		} catch (NotFoundException $e) {
172
-			return new DataResponse(
173
-				[
174
-					'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id])
175
-				],
176
-				Http::STATUS_NOT_FOUND
177
-			);
178
-		}
179
-
180
-		$this->updateStorageStatus($storage, $testOnly);
181
-
182
-		return new DataResponse(
183
-			$this->formatStorageForUI($storage),
184
-			Http::STATUS_OK
185
-		);
186
-
187
-	}
43
+    /**
44
+     * Creates a new global storages controller.
45
+     *
46
+     * @param string $AppName application name
47
+     * @param IRequest $request request object
48
+     * @param IL10N $l10n l10n service
49
+     * @param GlobalStoragesService $globalStoragesService storage service
50
+     * @param ILogger $logger
51
+     */
52
+    public function __construct(
53
+        $AppName,
54
+        IRequest $request,
55
+        IL10N $l10n,
56
+        GlobalStoragesService $globalStoragesService,
57
+        ILogger $logger
58
+    ) {
59
+        parent::__construct(
60
+            $AppName,
61
+            $request,
62
+            $l10n,
63
+            $globalStoragesService,
64
+            $logger
65
+        );
66
+    }
67
+
68
+    /**
69
+     * Create an external storage entry.
70
+     *
71
+     * @param string $mountPoint storage mount point
72
+     * @param string $backend backend identifier
73
+     * @param string $authMechanism authentication mechanism identifier
74
+     * @param array $backendOptions backend-specific options
75
+     * @param array $mountOptions mount-specific options
76
+     * @param array $applicableUsers users for which to mount the storage
77
+     * @param array $applicableGroups groups for which to mount the storage
78
+     * @param int $priority priority
79
+     *
80
+     * @return DataResponse
81
+     */
82
+    public function create(
83
+        $mountPoint,
84
+        $backend,
85
+        $authMechanism,
86
+        $backendOptions,
87
+        $mountOptions,
88
+        $applicableUsers,
89
+        $applicableGroups,
90
+        $priority
91
+    ) {
92
+        $newStorage = $this->createStorage(
93
+            $mountPoint,
94
+            $backend,
95
+            $authMechanism,
96
+            $backendOptions,
97
+            $mountOptions,
98
+            $applicableUsers,
99
+            $applicableGroups,
100
+            $priority
101
+        );
102
+        if ($newStorage instanceof DataResponse) {
103
+            return $newStorage;
104
+        }
105
+
106
+        $response = $this->validate($newStorage);
107
+        if (!empty($response)) {
108
+            return $response;
109
+        }
110
+
111
+        $newStorage = $this->service->addStorage($newStorage);
112
+
113
+        $this->updateStorageStatus($newStorage);
114
+
115
+        return new DataResponse(
116
+            $this->formatStorageForUI($newStorage),
117
+            Http::STATUS_CREATED
118
+        );
119
+    }
120
+
121
+    /**
122
+     * Update an external storage entry.
123
+     *
124
+     * @param int $id storage id
125
+     * @param string $mountPoint storage mount point
126
+     * @param string $backend backend identifier
127
+     * @param string $authMechanism authentication mechansim identifier
128
+     * @param array $backendOptions backend-specific options
129
+     * @param array $mountOptions mount-specific options
130
+     * @param array $applicableUsers users for which to mount the storage
131
+     * @param array $applicableGroups groups for which to mount the storage
132
+     * @param int $priority priority
133
+     * @param bool $testOnly whether to storage should only test the connection or do more things
134
+     *
135
+     * @return DataResponse
136
+     */
137
+    public function update(
138
+        $id,
139
+        $mountPoint,
140
+        $backend,
141
+        $authMechanism,
142
+        $backendOptions,
143
+        $mountOptions,
144
+        $applicableUsers,
145
+        $applicableGroups,
146
+        $priority,
147
+        $testOnly = true
148
+    ) {
149
+        $storage = $this->createStorage(
150
+            $mountPoint,
151
+            $backend,
152
+            $authMechanism,
153
+            $backendOptions,
154
+            $mountOptions,
155
+            $applicableUsers,
156
+            $applicableGroups,
157
+            $priority
158
+        );
159
+        if ($storage instanceof DataResponse) {
160
+            return $storage;
161
+        }
162
+        $storage->setId($id);
163
+
164
+        $response = $this->validate($storage);
165
+        if (!empty($response)) {
166
+            return $response;
167
+        }
168
+
169
+        try {
170
+            $storage = $this->service->updateStorage($storage);
171
+        } catch (NotFoundException $e) {
172
+            return new DataResponse(
173
+                [
174
+                    'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id])
175
+                ],
176
+                Http::STATUS_NOT_FOUND
177
+            );
178
+        }
179
+
180
+        $this->updateStorageStatus($storage, $testOnly);
181
+
182
+        return new DataResponse(
183
+            $this->formatStorageForUI($storage),
184
+            Http::STATUS_OK
185
+        );
186
+
187
+    }
188 188
 
189 189
 
190 190
 }
Please login to merge, or discard this patch.
lib/private/App/AppStore/Bundles/EducationBundle.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 	 * {@inheritDoc}
28 28
 	 */
29 29
 	public function getName() {
30
-		return (string)$this->l10n->t('Education Edition');
30
+		return (string) $this->l10n->t('Education Edition');
31 31
 	}
32 32
 
33 33
 	/**
Please login to merge, or discard this patch.
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -25,27 +25,27 @@
 block discarded – undo
25 25
 
26 26
 class EducationBundle extends Bundle {
27 27
 
28
-	/**
29
-	 * {@inheritDoc}
30
-	 */
31
-	public function getName() {
32
-		return (string)$this->l10n->t('Education Edition');
33
-	}
28
+    /**
29
+     * {@inheritDoc}
30
+     */
31
+    public function getName() {
32
+        return (string)$this->l10n->t('Education Edition');
33
+    }
34 34
 
35
-	/**
36
-	 * {@inheritDoc}
37
-	 */
38
-	public function getAppIdentifiers() {
39
-		return [
40
-			'zenodo',
41
-			'dashboard',
42
-			'circles',
43
-			'groupfolders',
44
-			'announcementcenter',
45
-			'quota_warning',
46
-			'orcid',
47
-			'user_saml',
48
-		];
49
-	}
35
+    /**
36
+     * {@inheritDoc}
37
+     */
38
+    public function getAppIdentifiers() {
39
+        return [
40
+            'zenodo',
41
+            'dashboard',
42
+            'circles',
43
+            'groupfolders',
44
+            'announcementcenter',
45
+            'quota_warning',
46
+            'orcid',
47
+            'user_saml',
48
+        ];
49
+    }
50 50
 
51 51
 }
Please login to merge, or discard this patch.
core/templates/403.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@
 block discarded – undo
1 1
 <?php
2 2
 // @codeCoverageIgnoreStart
3 3
 if(!isset($_)) {//standalone  page is not supported anymore - redirect to /
4
-	require_once '../../lib/base.php';
4
+    require_once '../../lib/base.php';
5 5
 
6
-	$urlGenerator = \OC::$server->getURLGenerator();
7
-	header('Location: ' . $urlGenerator->getAbsoluteURL('/'));
8
-	exit;
6
+    $urlGenerator = \OC::$server->getURLGenerator();
7
+    header('Location: ' . $urlGenerator->getAbsoluteURL('/'));
8
+    exit;
9 9
 }
10 10
 // @codeCoverageIgnoreEnd
11 11
 ?>
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@
 block discarded – undo
1 1
 <?php
2 2
 // @codeCoverageIgnoreStart
3
-if(!isset($_)) {//standalone  page is not supported anymore - redirect to /
3
+if (!isset($_)) {//standalone  page is not supported anymore - redirect to /
4 4
 	require_once '../../lib/base.php';
5 5
 
6 6
 	$urlGenerator = \OC::$server->getURLGenerator();
7
-	header('Location: ' . $urlGenerator->getAbsoluteURL('/'));
7
+	header('Location: '.$urlGenerator->getAbsoluteURL('/'));
8 8
 	exit;
9 9
 }
10 10
 // @codeCoverageIgnoreEnd
11 11
 ?>
12 12
 <ul>
13 13
 	<li class='error'>
14
-		<?php p($l->t( 'Access forbidden' )); ?><br>
15
-		<p class='hint'><?php if(isset($_['message'])) p($_['message'])?></p>
14
+		<?php p($l->t('Access forbidden')); ?><br>
15
+		<p class='hint'><?php if (isset($_['message'])) p($_['message'])?></p>
16 16
 	</li>
17 17
 </ul>
Please login to merge, or discard this patch.
core/templates/404.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,11 +4,11 @@
 block discarded – undo
4 4
 /** @var $theme OCP\Defaults */
5 5
 // @codeCoverageIgnoreStart
6 6
 if(!isset($_)) {//standalone  page is not supported anymore - redirect to /
7
-	require_once '../../lib/base.php';
7
+    require_once '../../lib/base.php';
8 8
 
9
-	$urlGenerator = \OC::$server->getURLGenerator();
10
-	header('Location: ' . $urlGenerator->getAbsoluteURL('/'));
11
-	exit;
9
+    $urlGenerator = \OC::$server->getURLGenerator();
10
+    header('Location: ' . $urlGenerator->getAbsoluteURL('/'));
11
+    exit;
12 12
 }
13 13
 // @codeCoverageIgnoreEnd
14 14
 ?>
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,11 +3,11 @@
 block discarded – undo
3 3
 /** @var $l \OCP\IL10N */
4 4
 /** @var $theme OCP\Defaults */
5 5
 // @codeCoverageIgnoreStart
6
-if(!isset($_)) {//standalone  page is not supported anymore - redirect to /
6
+if (!isset($_)) {//standalone  page is not supported anymore - redirect to /
7 7
 	require_once '../../lib/base.php';
8 8
 
9 9
 	$urlGenerator = \OC::$server->getURLGenerator();
10
-	header('Location: ' . $urlGenerator->getAbsoluteURL('/'));
10
+	header('Location: '.$urlGenerator->getAbsoluteURL('/'));
11 11
 	exit;
12 12
 }
13 13
 // @codeCoverageIgnoreEnd
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,10 +14,13 @@
 block discarded – undo
14 14
 ?>
15 15
 <?php if (isset($_['content'])): ?>
16 16
 	<?php print_unescaped($_['content']) ?>
17
-<?php else: ?>
17
+<?php else {
18
+    : ?>
18 19
 	<div class="body-login-container update">
19 20
 		<div class="icon-big icon-search icon-white"></div>
20
-		<h2><?php p($l->t('File not found')); ?></h2>
21
+		<h2><?php p($l->t('File not found'));
22
+}
23
+?></h2>
21 24
 		<p class="infogroup"><?php p($l->t('The document could not be found on the server. Maybe the share was deleted or has expired?')); ?></p>
22 25
 		<p><a class="button primary" href="<?php p(\OC::$server->getURLGenerator()->linkTo('', 'index.php')) ?>">
23 26
 			<?php p($l->t('Back to %s', [$theme->getName()])); ?>
Please login to merge, or discard this patch.