@@ -147,7 +147,7 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -33,161 +33,161 @@ |
||
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 | } |
@@ -233,7 +233,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -52,414 +52,414 @@ |
||
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 | } |
@@ -27,7 +27,7 @@ |
||
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 | /** |
@@ -23,28 +23,28 @@ |
||
23 | 23 | |
24 | 24 | class EducationBundle extends Bundle { |
25 | 25 | |
26 | - /** |
|
27 | - * {@inheritDoc} |
|
28 | - */ |
|
29 | - public function getName() { |
|
30 | - return (string)$this->l10n->t('Education Edition'); |
|
31 | - } |
|
26 | + /** |
|
27 | + * {@inheritDoc} |
|
28 | + */ |
|
29 | + public function getName() { |
|
30 | + return (string)$this->l10n->t('Education Edition'); |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * {@inheritDoc} |
|
35 | - */ |
|
36 | - public function getAppIdentifiers() { |
|
37 | - return [ |
|
38 | - 'zenodo', |
|
39 | - 'dashboard', |
|
40 | - 'circles', |
|
41 | - 'groupfolders', |
|
42 | - 'announcementcenter', |
|
43 | - 'admin_notifications', |
|
44 | - 'quota_warning', |
|
45 | - 'orcid', |
|
46 | - 'user_saml', |
|
47 | - ]; |
|
48 | - } |
|
33 | + /** |
|
34 | + * {@inheritDoc} |
|
35 | + */ |
|
36 | + public function getAppIdentifiers() { |
|
37 | + return [ |
|
38 | + 'zenodo', |
|
39 | + 'dashboard', |
|
40 | + 'circles', |
|
41 | + 'groupfolders', |
|
42 | + 'announcementcenter', |
|
43 | + 'admin_notifications', |
|
44 | + 'quota_warning', |
|
45 | + 'orcid', |
|
46 | + 'user_saml', |
|
47 | + ]; |
|
48 | + } |
|
49 | 49 | |
50 | 50 | } |
@@ -1,11 +1,11 @@ |
||
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 | ?> |
@@ -1,17 +1,17 @@ |
||
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> |
@@ -4,11 +4,11 @@ |
||
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 | ?> |
@@ -3,11 +3,11 @@ |
||
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 |
@@ -14,10 +14,13 @@ |
||
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', array($theme->getName()))); ?> |
@@ -24,7 +24,7 @@ |
||
24 | 24 | use OC\DB\QueryBuilder\QueryFunction; |
25 | 25 | |
26 | 26 | class PgSqlFunctionBuilder extends FunctionBuilder { |
27 | - public function concat($x, $y) { |
|
28 | - return new QueryFunction('(' . $this->helper->quoteColumnName($x) . ' || ' . $this->helper->quoteColumnName($y) . ')'); |
|
29 | - } |
|
27 | + public function concat($x, $y) { |
|
28 | + return new QueryFunction('(' . $this->helper->quoteColumnName($x) . ' || ' . $this->helper->quoteColumnName($y) . ')'); |
|
29 | + } |
|
30 | 30 | } |
@@ -25,6 +25,6 @@ |
||
25 | 25 | |
26 | 26 | class PgSqlFunctionBuilder extends FunctionBuilder { |
27 | 27 | public function concat($x, $y) { |
28 | - return new QueryFunction('(' . $this->helper->quoteColumnName($x) . ' || ' . $this->helper->quoteColumnName($y) . ')'); |
|
28 | + return new QueryFunction('('.$this->helper->quoteColumnName($x).' || '.$this->helper->quoteColumnName($y).')'); |
|
29 | 29 | } |
30 | 30 | } |
@@ -27,72 +27,72 @@ |
||
27 | 27 | |
28 | 28 | class RemoteShare implements ISetting { |
29 | 29 | |
30 | - /** @var IL10N */ |
|
31 | - protected $l; |
|
30 | + /** @var IL10N */ |
|
31 | + protected $l; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @param IL10N $l |
|
35 | - */ |
|
36 | - public function __construct(IL10N $l) { |
|
37 | - $this->l = $l; |
|
38 | - } |
|
33 | + /** |
|
34 | + * @param IL10N $l |
|
35 | + */ |
|
36 | + public function __construct(IL10N $l) { |
|
37 | + $this->l = $l; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @return string Lowercase a-z and underscore only identifier |
|
42 | - * @since 11.0.0 |
|
43 | - */ |
|
44 | - public function getIdentifier() { |
|
45 | - return 'remote_share'; |
|
46 | - } |
|
40 | + /** |
|
41 | + * @return string Lowercase a-z and underscore only identifier |
|
42 | + * @since 11.0.0 |
|
43 | + */ |
|
44 | + public function getIdentifier() { |
|
45 | + return 'remote_share'; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @return string A translated string |
|
50 | - * @since 11.0.0 |
|
51 | - */ |
|
52 | - public function getName() { |
|
53 | - return $this->l->t('A file or folder was shared from <strong>another server</strong>'); |
|
54 | - } |
|
48 | + /** |
|
49 | + * @return string A translated string |
|
50 | + * @since 11.0.0 |
|
51 | + */ |
|
52 | + public function getName() { |
|
53 | + return $this->l->t('A file or folder was shared from <strong>another server</strong>'); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @return int whether the filter should be rather on the top or bottom of |
|
58 | - * the admin section. The filters are arranged in ascending order of the |
|
59 | - * priority values. It is required to return a value between 0 and 100. |
|
60 | - * @since 11.0.0 |
|
61 | - */ |
|
62 | - public function getPriority() { |
|
63 | - return 11; |
|
64 | - } |
|
56 | + /** |
|
57 | + * @return int whether the filter should be rather on the top or bottom of |
|
58 | + * the admin section. The filters are arranged in ascending order of the |
|
59 | + * priority values. It is required to return a value between 0 and 100. |
|
60 | + * @since 11.0.0 |
|
61 | + */ |
|
62 | + public function getPriority() { |
|
63 | + return 11; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @return bool True when the option can be changed for the stream |
|
68 | - * @since 11.0.0 |
|
69 | - */ |
|
70 | - public function canChangeStream() { |
|
71 | - return true; |
|
72 | - } |
|
66 | + /** |
|
67 | + * @return bool True when the option can be changed for the stream |
|
68 | + * @since 11.0.0 |
|
69 | + */ |
|
70 | + public function canChangeStream() { |
|
71 | + return true; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return bool True when the option can be changed for the stream |
|
76 | - * @since 11.0.0 |
|
77 | - */ |
|
78 | - public function isDefaultEnabledStream() { |
|
79 | - return true; |
|
80 | - } |
|
74 | + /** |
|
75 | + * @return bool True when the option can be changed for the stream |
|
76 | + * @since 11.0.0 |
|
77 | + */ |
|
78 | + public function isDefaultEnabledStream() { |
|
79 | + return true; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @return bool True when the option can be changed for the mail |
|
84 | - * @since 11.0.0 |
|
85 | - */ |
|
86 | - public function canChangeMail() { |
|
87 | - return true; |
|
88 | - } |
|
82 | + /** |
|
83 | + * @return bool True when the option can be changed for the mail |
|
84 | + * @since 11.0.0 |
|
85 | + */ |
|
86 | + public function canChangeMail() { |
|
87 | + return true; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * @return bool True when the option can be changed for the stream |
|
92 | - * @since 11.0.0 |
|
93 | - */ |
|
94 | - public function isDefaultEnabledMail() { |
|
95 | - return false; |
|
96 | - } |
|
90 | + /** |
|
91 | + * @return bool True when the option can be changed for the stream |
|
92 | + * @since 11.0.0 |
|
93 | + */ |
|
94 | + public function isDefaultEnabledMail() { |
|
95 | + return false; |
|
96 | + } |
|
97 | 97 | } |
98 | 98 |
@@ -27,72 +27,72 @@ |
||
27 | 27 | |
28 | 28 | class Shared implements ISetting { |
29 | 29 | |
30 | - /** @var IL10N */ |
|
31 | - protected $l; |
|
30 | + /** @var IL10N */ |
|
31 | + protected $l; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @param IL10N $l |
|
35 | - */ |
|
36 | - public function __construct(IL10N $l) { |
|
37 | - $this->l = $l; |
|
38 | - } |
|
33 | + /** |
|
34 | + * @param IL10N $l |
|
35 | + */ |
|
36 | + public function __construct(IL10N $l) { |
|
37 | + $this->l = $l; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @return string Lowercase a-z and underscore only identifier |
|
42 | - * @since 11.0.0 |
|
43 | - */ |
|
44 | - public function getIdentifier() { |
|
45 | - return 'shared'; |
|
46 | - } |
|
40 | + /** |
|
41 | + * @return string Lowercase a-z and underscore only identifier |
|
42 | + * @since 11.0.0 |
|
43 | + */ |
|
44 | + public function getIdentifier() { |
|
45 | + return 'shared'; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @return string A translated string |
|
50 | - * @since 11.0.0 |
|
51 | - */ |
|
52 | - public function getName() { |
|
53 | - return $this->l->t('A file or folder has been <strong>shared</strong>'); |
|
54 | - } |
|
48 | + /** |
|
49 | + * @return string A translated string |
|
50 | + * @since 11.0.0 |
|
51 | + */ |
|
52 | + public function getName() { |
|
53 | + return $this->l->t('A file or folder has been <strong>shared</strong>'); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @return int whether the filter should be rather on the top or bottom of |
|
58 | - * the admin section. The filters are arranged in ascending order of the |
|
59 | - * priority values. It is required to return a value between 0 and 100. |
|
60 | - * @since 11.0.0 |
|
61 | - */ |
|
62 | - public function getPriority() { |
|
63 | - return 10; |
|
64 | - } |
|
56 | + /** |
|
57 | + * @return int whether the filter should be rather on the top or bottom of |
|
58 | + * the admin section. The filters are arranged in ascending order of the |
|
59 | + * priority values. It is required to return a value between 0 and 100. |
|
60 | + * @since 11.0.0 |
|
61 | + */ |
|
62 | + public function getPriority() { |
|
63 | + return 10; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @return bool True when the option can be changed for the stream |
|
68 | - * @since 11.0.0 |
|
69 | - */ |
|
70 | - public function canChangeStream() { |
|
71 | - return true; |
|
72 | - } |
|
66 | + /** |
|
67 | + * @return bool True when the option can be changed for the stream |
|
68 | + * @since 11.0.0 |
|
69 | + */ |
|
70 | + public function canChangeStream() { |
|
71 | + return true; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return bool True when the option can be changed for the stream |
|
76 | - * @since 11.0.0 |
|
77 | - */ |
|
78 | - public function isDefaultEnabledStream() { |
|
79 | - return true; |
|
80 | - } |
|
74 | + /** |
|
75 | + * @return bool True when the option can be changed for the stream |
|
76 | + * @since 11.0.0 |
|
77 | + */ |
|
78 | + public function isDefaultEnabledStream() { |
|
79 | + return true; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @return bool True when the option can be changed for the mail |
|
84 | - * @since 11.0.0 |
|
85 | - */ |
|
86 | - public function canChangeMail() { |
|
87 | - return true; |
|
88 | - } |
|
82 | + /** |
|
83 | + * @return bool True when the option can be changed for the mail |
|
84 | + * @since 11.0.0 |
|
85 | + */ |
|
86 | + public function canChangeMail() { |
|
87 | + return true; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * @return bool True when the option can be changed for the stream |
|
92 | - * @since 11.0.0 |
|
93 | - */ |
|
94 | - public function isDefaultEnabledMail() { |
|
95 | - return false; |
|
96 | - } |
|
90 | + /** |
|
91 | + * @return bool True when the option can be changed for the stream |
|
92 | + * @since 11.0.0 |
|
93 | + */ |
|
94 | + public function isDefaultEnabledMail() { |
|
95 | + return false; |
|
96 | + } |
|
97 | 97 | } |
98 | 98 |
@@ -24,18 +24,18 @@ |
||
24 | 24 | use OCP\Files\ObjectStore\IObjectStore; |
25 | 25 | |
26 | 26 | class S3 implements IObjectStore { |
27 | - use S3ConnectionTrait; |
|
28 | - use S3ObjectTrait; |
|
27 | + use S3ConnectionTrait; |
|
28 | + use S3ObjectTrait; |
|
29 | 29 | |
30 | - public function __construct($parameters) { |
|
31 | - $this->parseParams($parameters); |
|
32 | - } |
|
30 | + public function __construct($parameters) { |
|
31 | + $this->parseParams($parameters); |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * @return string the container or bucket name where objects are stored |
|
36 | - * @since 7.0.0 |
|
37 | - */ |
|
38 | - public function getStorageId() { |
|
39 | - return $this->id; |
|
40 | - } |
|
34 | + /** |
|
35 | + * @return string the container or bucket name where objects are stored |
|
36 | + * @since 7.0.0 |
|
37 | + */ |
|
38 | + public function getStorageId() { |
|
39 | + return $this->id; |
|
40 | + } |
|
41 | 41 | } |