@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | * the transformed app id, defaults to OCA\ |
59 | 59 | * @return string the starting namespace for the app |
60 | 60 | */ |
61 | - public static function buildAppNamespace(string $appId, string $topNamespace='OCA\\'): string { |
|
61 | + public static function buildAppNamespace(string $appId, string $topNamespace = 'OCA\\'): string { |
|
62 | 62 | // Hit the cache! |
63 | 63 | if (isset(self::$nameSpaceCache[$appId])) { |
64 | - return $topNamespace . self::$nameSpaceCache[$appId]; |
|
64 | + return $topNamespace.self::$nameSpaceCache[$appId]; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | $appInfo = \OC_App::getAppInfo($appId); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | - return $topNamespace . self::$nameSpaceCache[$appId]; |
|
86 | + return $topNamespace.self::$nameSpaceCache[$appId]; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | // first try $controllerName then go for \OCA\AppName\Controller\$controllerName |
108 | 108 | try { |
109 | 109 | $controller = $container->query($controllerName); |
110 | - } catch(QueryException $e) { |
|
110 | + } catch (QueryException $e) { |
|
111 | 111 | if (strpos($controllerName, '\\Controller\\') !== false) { |
112 | 112 | // This is from a global registered app route that is not enabled. |
113 | 113 | [/*OC(A)*/, $app, /* Controller/Name*/] = explode('\\', $controllerName, 3); |
114 | - throw new HintException('App ' . strtolower($app) . ' is not enabled'); |
|
114 | + throw new HintException('App '.strtolower($app).' is not enabled'); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | if ($appName === 'core') { |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | } else { |
120 | 120 | $appNameSpace = self::buildAppNamespace($appName); |
121 | 121 | } |
122 | - $controllerName = $appNameSpace . '\\Controller\\' . $controllerName; |
|
122 | + $controllerName = $appNameSpace.'\\Controller\\'.$controllerName; |
|
123 | 123 | $controller = $container->query($controllerName); |
124 | 124 | } |
125 | 125 | |
@@ -137,17 +137,17 @@ discard block |
||
137 | 137 | |
138 | 138 | $io = $container[IOutput::class]; |
139 | 139 | |
140 | - if(!is_null($httpHeaders)) { |
|
140 | + if (!is_null($httpHeaders)) { |
|
141 | 141 | $io->setHeader($httpHeaders); |
142 | 142 | } |
143 | 143 | |
144 | - foreach($responseHeaders as $name => $value) { |
|
145 | - $io->setHeader($name . ': ' . $value); |
|
144 | + foreach ($responseHeaders as $name => $value) { |
|
145 | + $io->setHeader($name.': '.$value); |
|
146 | 146 | } |
147 | 147 | |
148 | - foreach($responseCookies as $name => $value) { |
|
148 | + foreach ($responseCookies as $name => $value) { |
|
149 | 149 | $expireDate = null; |
150 | - if($value['expireDate'] instanceof \DateTime) { |
|
150 | + if ($value['expireDate'] instanceof \DateTime) { |
|
151 | 151 | $expireDate = $value['expireDate']->getTimestamp(); |
152 | 152 | } |
153 | 153 | $io->setCookie( |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | */ |
170 | 170 | $emptyResponse = false; |
171 | 171 | if (preg_match('/^HTTP\/\d\.\d (\d{3}) .*$/', $httpHeaders, $matches)) { |
172 | - $status = (int)$matches[1]; |
|
172 | + $status = (int) $matches[1]; |
|
173 | 173 | if ($status === Http::STATUS_NO_CONTENT || $status === Http::STATUS_NOT_MODIFIED) { |
174 | 174 | $emptyResponse = true; |
175 | 175 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | if ($response instanceof ICallbackResponse) { |
180 | 180 | $response->callback($io); |
181 | 181 | } else if (!is_null($output)) { |
182 | - $io->setHeader('Content-Length: ' . strlen($output)); |
|
182 | + $io->setHeader('Content-Length: '.strlen($output)); |
|
183 | 183 | $io->setOutput($output); |
184 | 184 | } |
185 | 185 | } |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | |
207 | 207 | $dispatcher = $container['Dispatcher']; |
208 | 208 | |
209 | - list(, , $output) = $dispatcher->dispatch($controller, $methodName); |
|
209 | + list(,, $output) = $dispatcher->dispatch($controller, $methodName); |
|
210 | 210 | return $output; |
211 | 211 | } |
212 | 212 |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | return parent::connect(); |
65 | 65 | } catch (DBALException $e) { |
66 | 66 | // throw a new exception to prevent leaking info from the stacktrace |
67 | - throw new DBALException('Failed to connect to the database: ' . $e->getMessage(), $e->getCode()); |
|
67 | + throw new DBALException('Failed to connect to the database: '.$e->getMessage(), $e->getCode()); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | // 0 is the method where we use `getCallerBacktrace` |
117 | 117 | // 1 is the target method which uses the method we want to log |
118 | 118 | if (isset($traces[1])) { |
119 | - return $traces[1]['file'] . ':' . $traces[1]['line']; |
|
119 | + return $traces[1]['file'].':'.$traces[1]['line']; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | return ''; |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @param int $offset |
161 | 161 | * @return \Doctrine\DBAL\Driver\Statement The prepared statement. |
162 | 162 | */ |
163 | - public function prepare($statement, $limit=null, $offset=null) { |
|
163 | + public function prepare($statement, $limit = null, $offset = null) { |
|
164 | 164 | if ($limit === -1) { |
165 | 165 | $limit = null; |
166 | 166 | } |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | $insertQb = $this->getQueryBuilder(); |
290 | 290 | $insertQb->insert($table) |
291 | 291 | ->values( |
292 | - array_map(function ($value) use ($insertQb) { |
|
292 | + array_map(function($value) use ($insertQb) { |
|
293 | 293 | return $insertQb->createNamedParameter($value, $this->getType($value)); |
294 | 294 | }, array_merge($keys, $values)) |
295 | 295 | ); |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | throw new \BadMethodCallException('Can not lock a new table until the previous lock is released.'); |
334 | 334 | } |
335 | 335 | |
336 | - $tableName = $this->tablePrefix . $tableName; |
|
336 | + $tableName = $this->tablePrefix.$tableName; |
|
337 | 337 | $this->lockedTable = $tableName; |
338 | 338 | $this->adapter->lockTable($tableName); |
339 | 339 | } |
@@ -354,11 +354,11 @@ discard block |
||
354 | 354 | * @return string |
355 | 355 | */ |
356 | 356 | public function getError() { |
357 | - $msg = $this->errorCode() . ': '; |
|
357 | + $msg = $this->errorCode().': '; |
|
358 | 358 | $errorInfo = $this->errorInfo(); |
359 | 359 | if (is_array($errorInfo)) { |
360 | - $msg .= 'SQLSTATE = '.$errorInfo[0] . ', '; |
|
361 | - $msg .= 'Driver Code = '.$errorInfo[1] . ', '; |
|
360 | + $msg .= 'SQLSTATE = '.$errorInfo[0].', '; |
|
361 | + $msg .= 'Driver Code = '.$errorInfo[1].', '; |
|
362 | 362 | $msg .= 'Driver Message = '.$errorInfo[2]; |
363 | 363 | } |
364 | 364 | return $msg; |
@@ -370,9 +370,9 @@ discard block |
||
370 | 370 | * @param string $table table name without the prefix |
371 | 371 | */ |
372 | 372 | public function dropTable($table) { |
373 | - $table = $this->tablePrefix . trim($table); |
|
373 | + $table = $this->tablePrefix.trim($table); |
|
374 | 374 | $schema = $this->getSchemaManager(); |
375 | - if($schema->tablesExist([$table])) { |
|
375 | + if ($schema->tablesExist([$table])) { |
|
376 | 376 | $schema->dropTable($table); |
377 | 377 | } |
378 | 378 | } |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | * @return bool |
385 | 385 | */ |
386 | 386 | public function tableExists($table) { |
387 | - $table = $this->tablePrefix . trim($table); |
|
387 | + $table = $this->tablePrefix.trim($table); |
|
388 | 388 | $schema = $this->getSchemaManager(); |
389 | 389 | return $schema->tablesExist([$table]); |
390 | 390 | } |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | * @return string |
396 | 396 | */ |
397 | 397 | protected function replaceTablePrefix($statement) { |
398 | - return str_replace( '*PREFIX*', $this->tablePrefix, $statement ); |
|
398 | + return str_replace('*PREFIX*', $this->tablePrefix, $statement); |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | /** |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | if ($appName === 'core') { |
79 | - $this->migrationsPath = \OC::$SERVERROOT . '/core/Migrations'; |
|
79 | + $this->migrationsPath = \OC::$SERVERROOT.'/core/Migrations'; |
|
80 | 80 | $this->migrationsNamespace = 'OC\\Core\\Migrations'; |
81 | 81 | $this->checkOracle = true; |
82 | 82 | } else { |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | $appPath = $appLocator->getAppPath($appName); |
87 | 87 | $namespace = App::buildAppNamespace($appName); |
88 | 88 | $this->migrationsPath = "$appPath/lib/Migration"; |
89 | - $this->migrationsNamespace = $namespace . '\\Migration'; |
|
89 | + $this->migrationsNamespace = $namespace.'\\Migration'; |
|
90 | 90 | |
91 | 91 | $infoParser = new InfoParser(); |
92 | - $info = $infoParser->parse($appPath . '/appinfo/info.xml'); |
|
92 | + $info = $infoParser->parse($appPath.'/appinfo/info.xml'); |
|
93 | 93 | if (!isset($info['dependencies']['database'])) { |
94 | 94 | $this->checkOracle = true; |
95 | 95 | } else { |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | \RegexIterator::GET_MATCH); |
224 | 224 | |
225 | 225 | $files = array_keys(iterator_to_array($iterator)); |
226 | - uasort($files, function ($a, $b) { |
|
226 | + uasort($files, function($a, $b) { |
|
227 | 227 | preg_match('/^Version(\d+)Date(\d+)\\.php$/', basename($a), $matchA); |
228 | 228 | preg_match('/^Version(\d+)Date(\d+)\\.php$/', basename($b), $matchB); |
229 | 229 | if (!empty($matchA) && !empty($matchB)) { |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @return string |
302 | 302 | */ |
303 | 303 | public function getMigrationsTableName() { |
304 | - return $this->connection->getPrefix() . 'migrations'; |
|
304 | + return $this->connection->getPrefix().'migrations'; |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | /** |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | * @return mixed|null|string |
330 | 330 | */ |
331 | 331 | public function getMigration($alias) { |
332 | - switch($alias) { |
|
332 | + switch ($alias) { |
|
333 | 333 | case 'current': |
334 | 334 | return $this->getCurrentVersion(); |
335 | 335 | case 'next': |
@@ -468,12 +468,12 @@ discard block |
||
468 | 468 | $instance = $this->createInstance($version); |
469 | 469 | |
470 | 470 | if (!$schemaOnly) { |
471 | - $instance->preSchemaChange($this->output, function () { |
|
471 | + $instance->preSchemaChange($this->output, function() { |
|
472 | 472 | return new SchemaWrapper($this->connection); |
473 | 473 | }, ['tablePrefix' => $this->connection->getPrefix()]); |
474 | 474 | } |
475 | 475 | |
476 | - $toSchema = $instance->changeSchema($this->output, function () { |
|
476 | + $toSchema = $instance->changeSchema($this->output, function() { |
|
477 | 477 | return new SchemaWrapper($this->connection); |
478 | 478 | }, ['tablePrefix' => $this->connection->getPrefix()]); |
479 | 479 | |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | } |
489 | 489 | |
490 | 490 | if (!$schemaOnly) { |
491 | - $instance->postSchemaChange($this->output, function () { |
|
491 | + $instance->postSchemaChange($this->output, function() { |
|
492 | 492 | return new SchemaWrapper($this->connection); |
493 | 493 | }, ['tablePrefix' => $this->connection->getPrefix()]); |
494 | 494 | } |
@@ -504,26 +504,26 @@ discard block |
||
504 | 504 | $sourceTable = $sourceSchema->getTable($table->getName()); |
505 | 505 | } catch (SchemaException $e) { |
506 | 506 | if (\strlen($table->getName()) - $prefixLength > 27) { |
507 | - throw new \InvalidArgumentException('Table name "' . $table->getName() . '" is too long.'); |
|
507 | + throw new \InvalidArgumentException('Table name "'.$table->getName().'" is too long.'); |
|
508 | 508 | } |
509 | 509 | $sourceTable = null; |
510 | 510 | } |
511 | 511 | |
512 | 512 | foreach ($table->getColumns() as $thing) { |
513 | 513 | if ((!$sourceTable instanceof Table || !$sourceTable->hasColumn($thing->getName())) && \strlen($thing->getName()) > 30) { |
514 | - throw new \InvalidArgumentException('Column name "' . $table->getName() . '"."' . $thing->getName() . '" is too long.'); |
|
514 | + throw new \InvalidArgumentException('Column name "'.$table->getName().'"."'.$thing->getName().'" is too long.'); |
|
515 | 515 | } |
516 | 516 | } |
517 | 517 | |
518 | 518 | foreach ($table->getIndexes() as $thing) { |
519 | 519 | if ((!$sourceTable instanceof Table || !$sourceTable->hasIndex($thing->getName())) && \strlen($thing->getName()) > 30) { |
520 | - throw new \InvalidArgumentException('Index name "' . $table->getName() . '"."' . $thing->getName() . '" is too long.'); |
|
520 | + throw new \InvalidArgumentException('Index name "'.$table->getName().'"."'.$thing->getName().'" is too long.'); |
|
521 | 521 | } |
522 | 522 | } |
523 | 523 | |
524 | 524 | foreach ($table->getForeignKeys() as $thing) { |
525 | 525 | if ((!$sourceTable instanceof Table || !$sourceTable->hasForeignKey($thing->getName())) && \strlen($thing->getName()) > 30) { |
526 | - throw new \InvalidArgumentException('Foreign key name "' . $table->getName() . '"."' . $thing->getName() . '" is too long.'); |
|
526 | + throw new \InvalidArgumentException('Foreign key name "'.$table->getName().'"."'.$thing->getName().'" is too long.'); |
|
527 | 527 | } |
528 | 528 | } |
529 | 529 | |
@@ -533,32 +533,32 @@ discard block |
||
533 | 533 | $isUsingDefaultName = $indexName === 'primary'; |
534 | 534 | |
535 | 535 | if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) { |
536 | - $defaultName = $table->getName() . '_pkey'; |
|
536 | + $defaultName = $table->getName().'_pkey'; |
|
537 | 537 | $isUsingDefaultName = strtolower($defaultName) === $indexName; |
538 | 538 | |
539 | 539 | if ($isUsingDefaultName) { |
540 | - $sequenceName = $table->getName() . '_' . implode('_', $primaryKey->getColumns()) . '_seq'; |
|
541 | - $sequences = array_filter($sequences, function (Sequence $sequence) use ($sequenceName) { |
|
540 | + $sequenceName = $table->getName().'_'.implode('_', $primaryKey->getColumns()).'_seq'; |
|
541 | + $sequences = array_filter($sequences, function(Sequence $sequence) use ($sequenceName) { |
|
542 | 542 | return $sequence->getName() !== $sequenceName; |
543 | 543 | }); |
544 | 544 | } |
545 | 545 | } else if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) { |
546 | - $defaultName = $table->getName() . '_seq'; |
|
546 | + $defaultName = $table->getName().'_seq'; |
|
547 | 547 | $isUsingDefaultName = strtolower($defaultName) === $indexName; |
548 | 548 | } |
549 | 549 | |
550 | 550 | if (!$isUsingDefaultName && \strlen($indexName) > 30) { |
551 | - throw new \InvalidArgumentException('Primary index name on "' . $table->getName() . '" is too long.'); |
|
551 | + throw new \InvalidArgumentException('Primary index name on "'.$table->getName().'" is too long.'); |
|
552 | 552 | } |
553 | 553 | if ($isUsingDefaultName && \strlen($table->getName()) - $prefixLength >= 23) { |
554 | - throw new \InvalidArgumentException('Primary index name on "' . $table->getName() . '" is too long.'); |
|
554 | + throw new \InvalidArgumentException('Primary index name on "'.$table->getName().'" is too long.'); |
|
555 | 555 | } |
556 | 556 | } |
557 | 557 | } |
558 | 558 | |
559 | 559 | foreach ($sequences as $sequence) { |
560 | 560 | if (!$sourceSchema->hasSequence($sequence->getName()) && \strlen($sequence->getName()) > 30) { |
561 | - throw new \InvalidArgumentException('Sequence name "' . $sequence->getName() . '" is too long.'); |
|
561 | + throw new \InvalidArgumentException('Sequence name "'.$sequence->getName().'" is too long.'); |
|
562 | 562 | } |
563 | 563 | } |
564 | 564 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | private function quoteKeys(array $data) { |
35 | 35 | $return = []; |
36 | 36 | $c = $this->getDatabasePlatform()->getIdentifierQuoteCharacter(); |
37 | - foreach($data as $key => $value) { |
|
37 | + foreach ($data as $key => $value) { |
|
38 | 38 | if ($key[0] !== $c) { |
39 | 39 | $return[$this->quoteIdentifier($key)] = $value; |
40 | 40 | } else { |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | * @param string $table table name without the prefix |
85 | 85 | */ |
86 | 86 | public function dropTable($table) { |
87 | - $table = $this->tablePrefix . trim($table); |
|
87 | + $table = $this->tablePrefix.trim($table); |
|
88 | 88 | $table = $this->quoteIdentifier($table); |
89 | 89 | $schema = $this->getSchemaManager(); |
90 | - if($schema->tablesExist([$table])) { |
|
90 | + if ($schema->tablesExist([$table])) { |
|
91 | 91 | $schema->dropTable($table); |
92 | 92 | } |
93 | 93 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @return bool |
100 | 100 | */ |
101 | 101 | public function tableExists($table) { |
102 | - $table = $this->tablePrefix . trim($table); |
|
102 | + $table = $this->tablePrefix.trim($table); |
|
103 | 103 | $table = $this->quoteIdentifier($table); |
104 | 104 | $schema = $this->getSchemaManager(); |
105 | 105 | return $schema->tablesExist([$table]); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | return new Index( |
78 | 78 | //TODO migrate existing uppercase indexes, then $this->connection->quoteIdentifier($index->getName()), |
79 | 79 | $index->getName(), |
80 | - array_map(function ($columnName) { |
|
80 | + array_map(function($columnName) { |
|
81 | 81 | return $this->connection->quoteIdentifier($columnName); |
82 | 82 | }, $index->getColumns()), |
83 | 83 | $index->isUnique(), |
@@ -96,11 +96,11 @@ discard block |
||
96 | 96 | */ |
97 | 97 | protected function quoteForeignKeyConstraint($fkc) { |
98 | 98 | return new ForeignKeyConstraint( |
99 | - array_map(function ($columnName) { |
|
99 | + array_map(function($columnName) { |
|
100 | 100 | return $this->connection->quoteIdentifier($columnName); |
101 | 101 | }, $fkc->getLocalColumns()), |
102 | 102 | $this->connection->quoteIdentifier($fkc->getForeignTableName()), |
103 | - array_map(function ($columnName) { |
|
103 | + array_map(function($columnName) { |
|
104 | 104 | return $this->connection->quoteIdentifier($columnName); |
105 | 105 | }, $fkc->getForeignColumns()), |
106 | 106 | $fkc->getName(), |
@@ -118,16 +118,16 @@ discard block |
||
118 | 118 | $schemaDiff = parent::getDiff($targetSchema, $connection); |
119 | 119 | |
120 | 120 | // oracle forces us to quote the identifiers |
121 | - $schemaDiff->newTables = array_map(function (Table $table) { |
|
121 | + $schemaDiff->newTables = array_map(function(Table $table) { |
|
122 | 122 | return new Table( |
123 | 123 | $this->connection->quoteIdentifier($table->getName()), |
124 | - array_map(function (Column $column) { |
|
124 | + array_map(function(Column $column) { |
|
125 | 125 | return $this->quoteColumn($column); |
126 | 126 | }, $table->getColumns()), |
127 | - array_map(function (Index $index) { |
|
127 | + array_map(function(Index $index) { |
|
128 | 128 | return $this->quoteIndex($index); |
129 | 129 | }, $table->getIndexes()), |
130 | - array_map(function (ForeignKeyConstraint $fck) { |
|
130 | + array_map(function(ForeignKeyConstraint $fck) { |
|
131 | 131 | return $this->quoteForeignKeyConstraint($fck); |
132 | 132 | }, $table->getForeignKeys()), |
133 | 133 | 0, |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | ); |
136 | 136 | }, $schemaDiff->newTables); |
137 | 137 | |
138 | - $schemaDiff->removedTables = array_map(function (Table $table) { |
|
138 | + $schemaDiff->removedTables = array_map(function(Table $table) { |
|
139 | 139 | return new Table( |
140 | 140 | $this->connection->quoteIdentifier($table->getName()), |
141 | 141 | $table->getColumns(), |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | foreach ($schemaDiff->changedTables as $tableDiff) { |
150 | 150 | $tableDiff->name = $this->connection->quoteIdentifier($tableDiff->name); |
151 | 151 | |
152 | - $tableDiff->addedColumns = array_map(function (Column $column) { |
|
152 | + $tableDiff->addedColumns = array_map(function(Column $column) { |
|
153 | 153 | return $this->quoteColumn($column); |
154 | 154 | }, $tableDiff->addedColumns); |
155 | 155 | |
@@ -159,43 +159,43 @@ discard block |
||
159 | 159 | $column->changedProperties = array_diff($column->changedProperties, ['autoincrement', 'unsigned']); |
160 | 160 | } |
161 | 161 | // remove columns that no longer have changed (because autoincrement and unsigned are not supported) |
162 | - $tableDiff->changedColumns = array_filter($tableDiff->changedColumns, function (ColumnDiff $column) { |
|
162 | + $tableDiff->changedColumns = array_filter($tableDiff->changedColumns, function(ColumnDiff $column) { |
|
163 | 163 | return count($column->changedProperties) > 0; |
164 | 164 | }); |
165 | 165 | |
166 | - $tableDiff->removedColumns = array_map(function (Column $column) { |
|
166 | + $tableDiff->removedColumns = array_map(function(Column $column) { |
|
167 | 167 | return $this->quoteColumn($column); |
168 | 168 | }, $tableDiff->removedColumns); |
169 | 169 | |
170 | - $tableDiff->renamedColumns = array_map(function (Column $column) { |
|
170 | + $tableDiff->renamedColumns = array_map(function(Column $column) { |
|
171 | 171 | return $this->quoteColumn($column); |
172 | 172 | }, $tableDiff->renamedColumns); |
173 | 173 | |
174 | - $tableDiff->addedIndexes = array_map(function (Index $index) { |
|
174 | + $tableDiff->addedIndexes = array_map(function(Index $index) { |
|
175 | 175 | return $this->quoteIndex($index); |
176 | 176 | }, $tableDiff->addedIndexes); |
177 | 177 | |
178 | - $tableDiff->changedIndexes = array_map(function (Index $index) { |
|
178 | + $tableDiff->changedIndexes = array_map(function(Index $index) { |
|
179 | 179 | return $this->quoteIndex($index); |
180 | 180 | }, $tableDiff->changedIndexes); |
181 | 181 | |
182 | - $tableDiff->removedIndexes = array_map(function (Index $index) { |
|
182 | + $tableDiff->removedIndexes = array_map(function(Index $index) { |
|
183 | 183 | return $this->quoteIndex($index); |
184 | 184 | }, $tableDiff->removedIndexes); |
185 | 185 | |
186 | - $tableDiff->renamedIndexes = array_map(function (Index $index) { |
|
186 | + $tableDiff->renamedIndexes = array_map(function(Index $index) { |
|
187 | 187 | return $this->quoteIndex($index); |
188 | 188 | }, $tableDiff->renamedIndexes); |
189 | 189 | |
190 | - $tableDiff->addedForeignKeys = array_map(function (ForeignKeyConstraint $fkc) { |
|
190 | + $tableDiff->addedForeignKeys = array_map(function(ForeignKeyConstraint $fkc) { |
|
191 | 191 | return $this->quoteForeignKeyConstraint($fkc); |
192 | 192 | }, $tableDiff->addedForeignKeys); |
193 | 193 | |
194 | - $tableDiff->changedForeignKeys = array_map(function (ForeignKeyConstraint $fkc) { |
|
194 | + $tableDiff->changedForeignKeys = array_map(function(ForeignKeyConstraint $fkc) { |
|
195 | 195 | return $this->quoteForeignKeyConstraint($fkc); |
196 | 196 | }, $tableDiff->changedForeignKeys); |
197 | 197 | |
198 | - $tableDiff->removedForeignKeys = array_map(function (ForeignKeyConstraint $fkc) { |
|
198 | + $tableDiff->removedForeignKeys = array_map(function(ForeignKeyConstraint $fkc) { |
|
199 | 199 | return $this->quoteForeignKeyConstraint($fkc); |
200 | 200 | }, $tableDiff->removedForeignKeys); |
201 | 201 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * @return string |
209 | 209 | */ |
210 | 210 | protected function generateTemporaryTableName($name) { |
211 | - return 'oc_' . uniqid(); |
|
211 | + return 'oc_'.uniqid(); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -217,16 +217,16 @@ discard block |
||
217 | 217 | */ |
218 | 218 | protected function convertStatementToScript($statement) { |
219 | 219 | if (substr($statement, -1) === ';') { |
220 | - return $statement . PHP_EOL . '/' . PHP_EOL; |
|
220 | + return $statement.PHP_EOL.'/'.PHP_EOL; |
|
221 | 221 | } |
222 | - $script = $statement . ';'; |
|
222 | + $script = $statement.';'; |
|
223 | 223 | $script .= PHP_EOL; |
224 | 224 | $script .= PHP_EOL; |
225 | 225 | return $script; |
226 | 226 | } |
227 | 227 | |
228 | 228 | protected function getFilterExpression() { |
229 | - return '/^"' . preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')) . '/'; |
|
229 | + return '/^"'.preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')).'/'; |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | } |
@@ -104,19 +104,19 @@ discard block |
||
104 | 104 | $this->logAllEvents(); |
105 | 105 | |
106 | 106 | $logLevel = $this->config->getSystemValue('loglevel', ILogger::WARN); |
107 | - $this->emit('\OC\Updater', 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]); |
|
107 | + $this->emit('\OC\Updater', 'setDebugLogLevel', [$logLevel, $this->logLevelNames[$logLevel]]); |
|
108 | 108 | $this->config->setSystemValue('loglevel', ILogger::DEBUG); |
109 | 109 | |
110 | 110 | $wasMaintenanceModeEnabled = $this->config->getSystemValueBool('maintenance'); |
111 | 111 | |
112 | - if(!$wasMaintenanceModeEnabled) { |
|
112 | + if (!$wasMaintenanceModeEnabled) { |
|
113 | 113 | $this->config->setSystemValue('maintenance', true); |
114 | 114 | $this->emit('\OC\Updater', 'maintenanceEnabled'); |
115 | 115 | } |
116 | 116 | |
117 | 117 | // Clear CAN_INSTALL file if not on git |
118 | 118 | if (\OC_Util::getChannel() !== 'git' && is_file(\OC::$configDir.'/CAN_INSTALL')) { |
119 | - if (!unlink(\OC::$configDir . '/CAN_INSTALL')) { |
|
119 | + if (!unlink(\OC::$configDir.'/CAN_INSTALL')) { |
|
120 | 120 | $this->log->error('Could not cleanup CAN_INSTALL from your config folder. Please remove this file manually.'); |
121 | 121 | } |
122 | 122 | } |
@@ -124,31 +124,31 @@ discard block |
||
124 | 124 | $installedVersion = $this->config->getSystemValue('version', '0.0.0'); |
125 | 125 | $currentVersion = implode('.', \OCP\Util::getVersion()); |
126 | 126 | |
127 | - $this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, ['app' => 'core']); |
|
127 | + $this->log->debug('starting upgrade from '.$installedVersion.' to '.$currentVersion, ['app' => 'core']); |
|
128 | 128 | |
129 | 129 | $success = true; |
130 | 130 | try { |
131 | 131 | $this->doUpgrade($currentVersion, $installedVersion); |
132 | 132 | } catch (HintException $exception) { |
133 | 133 | $this->log->logException($exception, ['app' => 'core']); |
134 | - $this->emit('\OC\Updater', 'failure', [$exception->getMessage() . ': ' .$exception->getHint()]); |
|
134 | + $this->emit('\OC\Updater', 'failure', [$exception->getMessage().': '.$exception->getHint()]); |
|
135 | 135 | $success = false; |
136 | 136 | } catch (\Exception $exception) { |
137 | 137 | $this->log->logException($exception, ['app' => 'core']); |
138 | - $this->emit('\OC\Updater', 'failure', [get_class($exception) . ': ' .$exception->getMessage()]); |
|
138 | + $this->emit('\OC\Updater', 'failure', [get_class($exception).': '.$exception->getMessage()]); |
|
139 | 139 | $success = false; |
140 | 140 | } |
141 | 141 | |
142 | 142 | $this->emit('\OC\Updater', 'updateEnd', [$success]); |
143 | 143 | |
144 | - if(!$wasMaintenanceModeEnabled && $success) { |
|
144 | + if (!$wasMaintenanceModeEnabled && $success) { |
|
145 | 145 | $this->config->setSystemValue('maintenance', false); |
146 | 146 | $this->emit('\OC\Updater', 'maintenanceDisabled'); |
147 | 147 | } else { |
148 | 148 | $this->emit('\OC\Updater', 'maintenanceActive'); |
149 | 149 | } |
150 | 150 | |
151 | - $this->emit('\OC\Updater', 'resetLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]); |
|
151 | + $this->emit('\OC\Updater', 'resetLogLevel', [$logLevel, $this->logLevelNames[$logLevel]]); |
|
152 | 152 | $this->config->setSystemValue('loglevel', $logLevel); |
153 | 153 | $this->config->setSystemValue('installed', true); |
154 | 154 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | */ |
163 | 163 | private function getAllowedPreviousVersions() { |
164 | 164 | // this should really be a JSON file |
165 | - require \OC::$SERVERROOT . '/version.php'; |
|
165 | + require \OC::$SERVERROOT.'/version.php'; |
|
166 | 166 | /** @var array $OC_VersionCanBeUpgradedFrom */ |
167 | 167 | return $OC_VersionCanBeUpgradedFrom; |
168 | 168 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | */ |
175 | 175 | private function getVendor() { |
176 | 176 | // this should really be a JSON file |
177 | - require \OC::$SERVERROOT . '/version.php'; |
|
177 | + require \OC::$SERVERROOT.'/version.php'; |
|
178 | 178 | /** @var string $vendor */ |
179 | 179 | return (string) $vendor; |
180 | 180 | } |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | */ |
189 | 189 | public function isUpgradePossible($oldVersion, $newVersion, array $allowedPreviousVersions) { |
190 | 190 | $version = explode('.', $oldVersion); |
191 | - $majorMinor = $version[0] . '.' . $version[1]; |
|
191 | + $majorMinor = $version[0].'.'.$version[1]; |
|
192 | 192 | |
193 | 193 | $currentVendor = $this->config->getAppValue('core', 'vendor', ''); |
194 | 194 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | // create empty file in data dir, so we can later find |
236 | 236 | // out that this is indeed an ownCloud data directory |
237 | 237 | // (in case it didn't exist before) |
238 | - file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', ''); |
|
238 | + file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data').'/.ocdata', ''); |
|
239 | 239 | |
240 | 240 | // pre-upgrade repairs |
241 | 241 | $repair = new Repair(Repair::getBeforeUpgradeRepairSteps(), \OC::$server->getEventDispatcher()); |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | foreach ($errors as $appId => $exception) { |
269 | 269 | /** @var \Exception $exception */ |
270 | 270 | $this->log->logException($exception, ['app' => $appId]); |
271 | - $this->emit('\OC\Updater', 'failure', [$appId . ': ' . $exception->getMessage()]); |
|
271 | + $this->emit('\OC\Updater', 'failure', [$appId.': '.$exception->getMessage()]); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | // post-upgrade repairs |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | $this->config->setAppValue('core', 'lastupdatedat', 0); |
280 | 280 | |
281 | 281 | // Check for code integrity if not disabled |
282 | - if(\OC::$server->getIntegrityCodeChecker()->isCodeCheckEnforced()) { |
|
282 | + if (\OC::$server->getIntegrityCodeChecker()->isCodeCheckEnforced()) { |
|
283 | 283 | $this->emit('\OC\Updater', 'startCheckCodeIntegrity'); |
284 | 284 | $this->checker->runInstanceVerification(); |
285 | 285 | $this->emit('\OC\Updater', 'finishedCheckCodeIntegrity'); |
@@ -320,12 +320,12 @@ discard block |
||
320 | 320 | * @link https://github.com/owncloud/core/issues/10980 |
321 | 321 | * @see \OC_App::updateApp |
322 | 322 | */ |
323 | - if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/preupdate.php')) { |
|
323 | + if (file_exists(\OC_App::getAppPath($appId).'/appinfo/preupdate.php')) { |
|
324 | 324 | $this->includePreUpdate($appId); |
325 | 325 | } |
326 | - if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/database.xml')) { |
|
326 | + if (file_exists(\OC_App::getAppPath($appId).'/appinfo/database.xml')) { |
|
327 | 327 | $this->emit('\OC\Updater', 'appSimulateUpdate', [$appId]); |
328 | - \OC_DB::simulateUpdateDbFromStructure(\OC_App::getAppPath($appId) . '/appinfo/database.xml'); |
|
328 | + \OC_DB::simulateUpdateDbFromStructure(\OC_App::getAppPath($appId).'/appinfo/database.xml'); |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 | } |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | * @param string $appId |
339 | 339 | */ |
340 | 340 | private function includePreUpdate($appId) { |
341 | - include \OC_App::getAppPath($appId) . '/appinfo/preupdate.php'; |
|
341 | + include \OC_App::getAppPath($appId).'/appinfo/preupdate.php'; |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | /** |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | foreach ($apps as $appId) { |
357 | 357 | $priorityType = false; |
358 | 358 | foreach ($priorityTypes as $type) { |
359 | - if(!isset($stacks[$type])) { |
|
359 | + if (!isset($stacks[$type])) { |
|
360 | 360 | $stacks[$type] = []; |
361 | 361 | } |
362 | 362 | if (\OC_App::isType($appId, [$type])) { |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | \OC_App::updateApp($appId); |
377 | 377 | $this->emit('\OC\Updater', 'appUpgrade', [$appId, \OC_App::getAppVersion($appId)]); |
378 | 378 | } |
379 | - if($type !== $pseudoOtherType) { |
|
379 | + if ($type !== $pseudoOtherType) { |
|
380 | 380 | // load authentication, filesystem and logging apps after |
381 | 381 | // upgrading them. Other apps my need to rely on modifying |
382 | 382 | // user and/or filesystem aspects. |
@@ -404,9 +404,9 @@ discard block |
||
404 | 404 | foreach ($apps as $app) { |
405 | 405 | // check if the app is compatible with this version of ownCloud |
406 | 406 | $info = OC_App::getAppInfo($app); |
407 | - if($info === null || !OC_App::isAppCompatible($version, $info)) { |
|
407 | + if ($info === null || !OC_App::isAppCompatible($version, $info)) { |
|
408 | 408 | if ($appManager->isShipped($app)) { |
409 | - throw new \UnexpectedValueException('The files of the app "' . $app . '" were not correctly replaced before running the update'); |
|
409 | + throw new \UnexpectedValueException('The files of the app "'.$app.'" were not correctly replaced before running the update'); |
|
410 | 410 | } |
411 | 411 | \OC::$server->getAppManager()->disableApp($app, true); |
412 | 412 | $this->emit('\OC\Updater', 'incompatibleAppDisabled', [$app]); |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | * @throws \Exception |
446 | 446 | */ |
447 | 447 | private function upgradeAppStoreApps(array $disabledApps, $reenable = false) { |
448 | - foreach($disabledApps as $app) { |
|
448 | + foreach ($disabledApps as $app) { |
|
449 | 449 | try { |
450 | 450 | $this->emit('\OC\Updater', 'checkAppStoreAppBefore', [$app]); |
451 | 451 | if ($this->installer->isUpdateAvailable($app)) { |
@@ -469,22 +469,22 @@ discard block |
||
469 | 469 | */ |
470 | 470 | private function emitRepairEvents() { |
471 | 471 | $dispatcher = \OC::$server->getEventDispatcher(); |
472 | - $dispatcher->addListener('\OC\Repair::warning', function ($event) { |
|
472 | + $dispatcher->addListener('\OC\Repair::warning', function($event) { |
|
473 | 473 | if ($event instanceof GenericEvent) { |
474 | 474 | $this->emit('\OC\Updater', 'repairWarning', $event->getArguments()); |
475 | 475 | } |
476 | 476 | }); |
477 | - $dispatcher->addListener('\OC\Repair::error', function ($event) { |
|
477 | + $dispatcher->addListener('\OC\Repair::error', function($event) { |
|
478 | 478 | if ($event instanceof GenericEvent) { |
479 | 479 | $this->emit('\OC\Updater', 'repairError', $event->getArguments()); |
480 | 480 | } |
481 | 481 | }); |
482 | - $dispatcher->addListener('\OC\Repair::info', function ($event) { |
|
482 | + $dispatcher->addListener('\OC\Repair::info', function($event) { |
|
483 | 483 | if ($event instanceof GenericEvent) { |
484 | 484 | $this->emit('\OC\Updater', 'repairInfo', $event->getArguments()); |
485 | 485 | } |
486 | 486 | }); |
487 | - $dispatcher->addListener('\OC\Repair::step', function ($event) { |
|
487 | + $dispatcher->addListener('\OC\Repair::step', function($event) { |
|
488 | 488 | if ($event instanceof GenericEvent) { |
489 | 489 | $this->emit('\OC\Updater', 'repairStep', $event->getArguments()); |
490 | 490 | } |
@@ -495,49 +495,49 @@ discard block |
||
495 | 495 | $log = $this->log; |
496 | 496 | |
497 | 497 | $dispatcher = \OC::$server->getEventDispatcher(); |
498 | - $dispatcher->addListener('\OC\DB\Migrator::executeSql', function ($event) use ($log) { |
|
498 | + $dispatcher->addListener('\OC\DB\Migrator::executeSql', function($event) use ($log) { |
|
499 | 499 | if (!$event instanceof GenericEvent) { |
500 | 500 | return; |
501 | 501 | } |
502 | - $log->info('\OC\DB\Migrator::executeSql: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']); |
|
502 | + $log->info('\OC\DB\Migrator::executeSql: '.$event->getSubject().' ('.$event->getArgument(0).' of '.$event->getArgument(1).')', ['app' => 'updater']); |
|
503 | 503 | }); |
504 | - $dispatcher->addListener('\OC\DB\Migrator::checkTable', function ($event) use ($log) { |
|
504 | + $dispatcher->addListener('\OC\DB\Migrator::checkTable', function($event) use ($log) { |
|
505 | 505 | if (!$event instanceof GenericEvent) { |
506 | 506 | return; |
507 | 507 | } |
508 | - $log->info('\OC\DB\Migrator::checkTable: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']); |
|
508 | + $log->info('\OC\DB\Migrator::checkTable: '.$event->getSubject().' ('.$event->getArgument(0).' of '.$event->getArgument(1).')', ['app' => 'updater']); |
|
509 | 509 | }); |
510 | 510 | |
511 | - $repairListener = function ($event) use ($log) { |
|
511 | + $repairListener = function($event) use ($log) { |
|
512 | 512 | if (!$event instanceof GenericEvent) { |
513 | 513 | return; |
514 | 514 | } |
515 | 515 | switch ($event->getSubject()) { |
516 | 516 | case '\OC\Repair::startProgress': |
517 | - $log->info('\OC\Repair::startProgress: Starting ... ' . $event->getArgument(1) . ' (' . $event->getArgument(0) . ')', ['app' => 'updater']); |
|
517 | + $log->info('\OC\Repair::startProgress: Starting ... '.$event->getArgument(1).' ('.$event->getArgument(0).')', ['app' => 'updater']); |
|
518 | 518 | break; |
519 | 519 | case '\OC\Repair::advance': |
520 | 520 | $desc = $event->getArgument(1); |
521 | 521 | if (empty($desc)) { |
522 | 522 | $desc = ''; |
523 | 523 | } |
524 | - $log->info('\OC\Repair::advance: ' . $desc . ' (' . $event->getArgument(0) . ')', ['app' => 'updater']); |
|
524 | + $log->info('\OC\Repair::advance: '.$desc.' ('.$event->getArgument(0).')', ['app' => 'updater']); |
|
525 | 525 | |
526 | 526 | break; |
527 | 527 | case '\OC\Repair::finishProgress': |
528 | 528 | $log->info('\OC\Repair::finishProgress', ['app' => 'updater']); |
529 | 529 | break; |
530 | 530 | case '\OC\Repair::step': |
531 | - $log->info('\OC\Repair::step: Repair step: ' . $event->getArgument(0), ['app' => 'updater']); |
|
531 | + $log->info('\OC\Repair::step: Repair step: '.$event->getArgument(0), ['app' => 'updater']); |
|
532 | 532 | break; |
533 | 533 | case '\OC\Repair::info': |
534 | - $log->info('\OC\Repair::info: Repair info: ' . $event->getArgument(0), ['app' => 'updater']); |
|
534 | + $log->info('\OC\Repair::info: Repair info: '.$event->getArgument(0), ['app' => 'updater']); |
|
535 | 535 | break; |
536 | 536 | case '\OC\Repair::warning': |
537 | - $log->warning('\OC\Repair::warning: Repair warning: ' . $event->getArgument(0), ['app' => 'updater']); |
|
537 | + $log->warning('\OC\Repair::warning: Repair warning: '.$event->getArgument(0), ['app' => 'updater']); |
|
538 | 538 | break; |
539 | 539 | case '\OC\Repair::error': |
540 | - $log->error('\OC\Repair::error: Repair error: ' . $event->getArgument(0), ['app' => 'updater']); |
|
540 | + $log->error('\OC\Repair::error: Repair error: '.$event->getArgument(0), ['app' => 'updater']); |
|
541 | 541 | break; |
542 | 542 | } |
543 | 543 | }; |
@@ -551,74 +551,74 @@ discard block |
||
551 | 551 | $dispatcher->addListener('\OC\Repair::error', $repairListener); |
552 | 552 | |
553 | 553 | |
554 | - $this->listen('\OC\Updater', 'maintenanceEnabled', function () use ($log) { |
|
554 | + $this->listen('\OC\Updater', 'maintenanceEnabled', function() use ($log) { |
|
555 | 555 | $log->info('\OC\Updater::maintenanceEnabled: Turned on maintenance mode', ['app' => 'updater']); |
556 | 556 | }); |
557 | - $this->listen('\OC\Updater', 'maintenanceDisabled', function () use ($log) { |
|
557 | + $this->listen('\OC\Updater', 'maintenanceDisabled', function() use ($log) { |
|
558 | 558 | $log->info('\OC\Updater::maintenanceDisabled: Turned off maintenance mode', ['app' => 'updater']); |
559 | 559 | }); |
560 | - $this->listen('\OC\Updater', 'maintenanceActive', function () use ($log) { |
|
560 | + $this->listen('\OC\Updater', 'maintenanceActive', function() use ($log) { |
|
561 | 561 | $log->info('\OC\Updater::maintenanceActive: Maintenance mode is kept active', ['app' => 'updater']); |
562 | 562 | }); |
563 | - $this->listen('\OC\Updater', 'updateEnd', function ($success) use ($log) { |
|
563 | + $this->listen('\OC\Updater', 'updateEnd', function($success) use ($log) { |
|
564 | 564 | if ($success) { |
565 | 565 | $log->info('\OC\Updater::updateEnd: Update successful', ['app' => 'updater']); |
566 | 566 | } else { |
567 | 567 | $log->error('\OC\Updater::updateEnd: Update failed', ['app' => 'updater']); |
568 | 568 | } |
569 | 569 | }); |
570 | - $this->listen('\OC\Updater', 'dbUpgradeBefore', function () use ($log) { |
|
570 | + $this->listen('\OC\Updater', 'dbUpgradeBefore', function() use ($log) { |
|
571 | 571 | $log->info('\OC\Updater::dbUpgradeBefore: Updating database schema', ['app' => 'updater']); |
572 | 572 | }); |
573 | - $this->listen('\OC\Updater', 'dbUpgrade', function () use ($log) { |
|
573 | + $this->listen('\OC\Updater', 'dbUpgrade', function() use ($log) { |
|
574 | 574 | $log->info('\OC\Updater::dbUpgrade: Updated database', ['app' => 'updater']); |
575 | 575 | }); |
576 | - $this->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use ($log) { |
|
576 | + $this->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function() use ($log) { |
|
577 | 577 | $log->info('\OC\Updater::dbSimulateUpgradeBefore: Checking whether the database schema can be updated (this can take a long time depending on the database size)', ['app' => 'updater']); |
578 | 578 | }); |
579 | - $this->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($log) { |
|
579 | + $this->listen('\OC\Updater', 'dbSimulateUpgrade', function() use ($log) { |
|
580 | 580 | $log->info('\OC\Updater::dbSimulateUpgrade: Checked database schema update', ['app' => 'updater']); |
581 | 581 | }); |
582 | - $this->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use ($log) { |
|
583 | - $log->info('\OC\Updater::incompatibleAppDisabled: Disabled incompatible app: ' . $app, ['app' => 'updater']); |
|
582 | + $this->listen('\OC\Updater', 'incompatibleAppDisabled', function($app) use ($log) { |
|
583 | + $log->info('\OC\Updater::incompatibleAppDisabled: Disabled incompatible app: '.$app, ['app' => 'updater']); |
|
584 | 584 | }); |
585 | - $this->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($log) { |
|
586 | - $log->info('\OC\Updater::checkAppStoreAppBefore: Checking for update of app "' . $app . '" in appstore', ['app' => 'updater']); |
|
585 | + $this->listen('\OC\Updater', 'checkAppStoreAppBefore', function($app) use ($log) { |
|
586 | + $log->info('\OC\Updater::checkAppStoreAppBefore: Checking for update of app "'.$app.'" in appstore', ['app' => 'updater']); |
|
587 | 587 | }); |
588 | - $this->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($log) { |
|
589 | - $log->info('\OC\Updater::upgradeAppStoreApp: Update app "' . $app . '" from appstore', ['app' => 'updater']); |
|
588 | + $this->listen('\OC\Updater', 'upgradeAppStoreApp', function($app) use ($log) { |
|
589 | + $log->info('\OC\Updater::upgradeAppStoreApp: Update app "'.$app.'" from appstore', ['app' => 'updater']); |
|
590 | 590 | }); |
591 | - $this->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($log) { |
|
592 | - $log->info('\OC\Updater::checkAppStoreApp: Checked for update of app "' . $app . '" in appstore', ['app' => 'updater']); |
|
591 | + $this->listen('\OC\Updater', 'checkAppStoreApp', function($app) use ($log) { |
|
592 | + $log->info('\OC\Updater::checkAppStoreApp: Checked for update of app "'.$app.'" in appstore', ['app' => 'updater']); |
|
593 | 593 | }); |
594 | - $this->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($log) { |
|
594 | + $this->listen('\OC\Updater', 'appUpgradeCheckBefore', function() use ($log) { |
|
595 | 595 | $log->info('\OC\Updater::appUpgradeCheckBefore: Checking updates of apps', ['app' => 'updater']); |
596 | 596 | }); |
597 | - $this->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($log) { |
|
598 | - $log->info('\OC\Updater::appSimulateUpdate: Checking whether the database schema for <' . $app . '> can be updated (this can take a long time depending on the database size)', ['app' => 'updater']); |
|
597 | + $this->listen('\OC\Updater', 'appSimulateUpdate', function($app) use ($log) { |
|
598 | + $log->info('\OC\Updater::appSimulateUpdate: Checking whether the database schema for <'.$app.'> can be updated (this can take a long time depending on the database size)', ['app' => 'updater']); |
|
599 | 599 | }); |
600 | - $this->listen('\OC\Updater', 'appUpgradeCheck', function () use ($log) { |
|
600 | + $this->listen('\OC\Updater', 'appUpgradeCheck', function() use ($log) { |
|
601 | 601 | $log->info('\OC\Updater::appUpgradeCheck: Checked database schema update for apps', ['app' => 'updater']); |
602 | 602 | }); |
603 | - $this->listen('\OC\Updater', 'appUpgradeStarted', function ($app) use ($log) { |
|
604 | - $log->info('\OC\Updater::appUpgradeStarted: Updating <' . $app . '> ...', ['app' => 'updater']); |
|
603 | + $this->listen('\OC\Updater', 'appUpgradeStarted', function($app) use ($log) { |
|
604 | + $log->info('\OC\Updater::appUpgradeStarted: Updating <'.$app.'> ...', ['app' => 'updater']); |
|
605 | 605 | }); |
606 | - $this->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($log) { |
|
607 | - $log->info('\OC\Updater::appUpgrade: Updated <' . $app . '> to ' . $version, ['app' => 'updater']); |
|
606 | + $this->listen('\OC\Updater', 'appUpgrade', function($app, $version) use ($log) { |
|
607 | + $log->info('\OC\Updater::appUpgrade: Updated <'.$app.'> to '.$version, ['app' => 'updater']); |
|
608 | 608 | }); |
609 | - $this->listen('\OC\Updater', 'failure', function ($message) use ($log) { |
|
610 | - $log->error('\OC\Updater::failure: ' . $message, ['app' => 'updater']); |
|
609 | + $this->listen('\OC\Updater', 'failure', function($message) use ($log) { |
|
610 | + $log->error('\OC\Updater::failure: '.$message, ['app' => 'updater']); |
|
611 | 611 | }); |
612 | - $this->listen('\OC\Updater', 'setDebugLogLevel', function () use ($log) { |
|
612 | + $this->listen('\OC\Updater', 'setDebugLogLevel', function() use ($log) { |
|
613 | 613 | $log->info('\OC\Updater::setDebugLogLevel: Set log level to debug', ['app' => 'updater']); |
614 | 614 | }); |
615 | - $this->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use ($log) { |
|
616 | - $log->info('\OC\Updater::resetLogLevel: Reset log level to ' . $logLevelName . '(' . $logLevel . ')', ['app' => 'updater']); |
|
615 | + $this->listen('\OC\Updater', 'resetLogLevel', function($logLevel, $logLevelName) use ($log) { |
|
616 | + $log->info('\OC\Updater::resetLogLevel: Reset log level to '.$logLevelName.'('.$logLevel.')', ['app' => 'updater']); |
|
617 | 617 | }); |
618 | - $this->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use ($log) { |
|
618 | + $this->listen('\OC\Updater', 'startCheckCodeIntegrity', function() use ($log) { |
|
619 | 619 | $log->info('\OC\Updater::startCheckCodeIntegrity: Starting code integrity check...', ['app' => 'updater']); |
620 | 620 | }); |
621 | - $this->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use ($log) { |
|
621 | + $this->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function() use ($log) { |
|
622 | 622 | $log->info('\OC\Updater::finishedCheckCodeIntegrity: Finished code integrity check', ['app' => 'updater']); |
623 | 623 | }); |
624 | 624 |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | } |
137 | 137 | $this->tags = $this->mapper->loadTags($this->owners, $this->type); |
138 | 138 | |
139 | - if(count($defaultTags) > 0 && count($this->tags) === 0) { |
|
139 | + if (count($defaultTags) > 0 && count($this->tags) === 0) { |
|
140 | 140 | $this->addMultiple($defaultTags, true); |
141 | 141 | } |
142 | 142 | } |
@@ -177,17 +177,17 @@ discard block |
||
177 | 177 | * @return array |
178 | 178 | */ |
179 | 179 | public function getTags() { |
180 | - if(!count($this->tags)) { |
|
180 | + if (!count($this->tags)) { |
|
181 | 181 | return []; |
182 | 182 | } |
183 | 183 | |
184 | - usort($this->tags, function ($a, $b) { |
|
184 | + usort($this->tags, function($a, $b) { |
|
185 | 185 | return strnatcasecmp($a->getName(), $b->getName()); |
186 | 186 | }); |
187 | 187 | $tagMap = []; |
188 | 188 | |
189 | - foreach($this->tags as $tag) { |
|
190 | - if($tag->getName() !== ITags::TAG_FAVORITE) { |
|
189 | + foreach ($this->tags as $tag) { |
|
190 | + if ($tag->getName() !== ITags::TAG_FAVORITE) { |
|
191 | 191 | $tagMap[] = $this->tagMap($tag); |
192 | 192 | } |
193 | 193 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public function getTagsForUser($user) { |
206 | 206 | return array_filter($this->tags, |
207 | - function ($tag) use ($user) { |
|
207 | + function($tag) use ($user) { |
|
208 | 208 | return $tag->getOwner() === $user; |
209 | 209 | } |
210 | 210 | ); |
@@ -225,25 +225,25 @@ discard block |
||
225 | 225 | $chunks = array_chunk($objIds, 900, false); |
226 | 226 | foreach ($chunks as $chunk) { |
227 | 227 | $result = $conn->executeQuery( |
228 | - 'SELECT `category`, `categoryid`, `objid` ' . |
|
229 | - 'FROM `' . self::RELATION_TABLE . '` r, `' . self::TAG_TABLE . '` ' . |
|
228 | + 'SELECT `category`, `categoryid`, `objid` '. |
|
229 | + 'FROM `'.self::RELATION_TABLE.'` r, `'.self::TAG_TABLE.'` '. |
|
230 | 230 | 'WHERE `categoryid` = `id` AND `uid` = ? AND r.`type` = ? AND `objid` IN (?)', |
231 | 231 | [$this->user, $this->type, $chunk], |
232 | 232 | [null, null, IQueryBuilder::PARAM_INT_ARRAY] |
233 | 233 | ); |
234 | 234 | while ($row = $result->fetch()) { |
235 | - $objId = (int)$row['objid']; |
|
235 | + $objId = (int) $row['objid']; |
|
236 | 236 | if (!isset($entries[$objId])) { |
237 | 237 | $entries[$objId] = []; |
238 | 238 | } |
239 | 239 | $entries[$objId][] = $row['category']; |
240 | 240 | } |
241 | 241 | if ($result === null) { |
242 | - \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
242 | + \OCP\Util::writeLog('core', __METHOD__.'DB error: '.\OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
243 | 243 | return false; |
244 | 244 | } |
245 | 245 | } |
246 | - } catch(\Exception $e) { |
|
246 | + } catch (\Exception $e) { |
|
247 | 247 | \OC::$server->getLogger()->logException($e, [ |
248 | 248 | 'message' => __METHOD__, |
249 | 249 | 'level' => ILogger::ERROR, |
@@ -267,18 +267,18 @@ discard block |
||
267 | 267 | public function getIdsForTag($tag) { |
268 | 268 | $result = null; |
269 | 269 | $tagId = false; |
270 | - if(is_numeric($tag)) { |
|
270 | + if (is_numeric($tag)) { |
|
271 | 271 | $tagId = $tag; |
272 | - } elseif(is_string($tag)) { |
|
272 | + } elseif (is_string($tag)) { |
|
273 | 273 | $tag = trim($tag); |
274 | - if($tag === '') { |
|
274 | + if ($tag === '') { |
|
275 | 275 | \OCP\Util::writeLog('core', __METHOD__.', Cannot use empty tag names', ILogger::DEBUG); |
276 | 276 | return false; |
277 | 277 | } |
278 | 278 | $tagId = $this->getTagId($tag); |
279 | 279 | } |
280 | 280 | |
281 | - if($tagId === false) { |
|
281 | + if ($tagId === false) { |
|
282 | 282 | $l10n = \OC::$server->getL10N('core'); |
283 | 283 | throw new \Exception( |
284 | 284 | $l10n->t('Could not find category "%s"', [$tag]) |
@@ -286,17 +286,17 @@ discard block |
||
286 | 286 | } |
287 | 287 | |
288 | 288 | $ids = []; |
289 | - $sql = 'SELECT `objid` FROM `' . self::RELATION_TABLE |
|
289 | + $sql = 'SELECT `objid` FROM `'.self::RELATION_TABLE |
|
290 | 290 | . '` WHERE `categoryid` = ?'; |
291 | 291 | |
292 | 292 | try { |
293 | 293 | $stmt = \OC_DB::prepare($sql); |
294 | 294 | $result = $stmt->execute([$tagId]); |
295 | 295 | if ($result === null) { |
296 | - \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
296 | + \OCP\Util::writeLog('core', __METHOD__.'DB error: '.\OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
297 | 297 | return false; |
298 | 298 | } |
299 | - } catch(\Exception $e) { |
|
299 | + } catch (\Exception $e) { |
|
300 | 300 | \OC::$server->getLogger()->logException($e, [ |
301 | 301 | 'message' => __METHOD__, |
302 | 302 | 'level' => ILogger::ERROR, |
@@ -305,9 +305,9 @@ discard block |
||
305 | 305 | return false; |
306 | 306 | } |
307 | 307 | |
308 | - if(!is_null($result)) { |
|
309 | - while( $row = $result->fetchRow()) { |
|
310 | - $id = (int)$row['objid']; |
|
308 | + if (!is_null($result)) { |
|
309 | + while ($row = $result->fetchRow()) { |
|
310 | + $id = (int) $row['objid']; |
|
311 | 311 | |
312 | 312 | if ($this->includeShared) { |
313 | 313 | // We have to check if we are really allowed to access the |
@@ -361,19 +361,19 @@ discard block |
||
361 | 361 | public function add($name) { |
362 | 362 | $name = trim($name); |
363 | 363 | |
364 | - if($name === '') { |
|
364 | + if ($name === '') { |
|
365 | 365 | \OCP\Util::writeLog('core', __METHOD__.', Cannot add an empty tag', ILogger::DEBUG); |
366 | 366 | return false; |
367 | 367 | } |
368 | - if($this->userHasTag($name, $this->user)) { |
|
369 | - \OCP\Util::writeLog('core', __METHOD__.', name: ' . $name. ' exists already', ILogger::DEBUG); |
|
368 | + if ($this->userHasTag($name, $this->user)) { |
|
369 | + \OCP\Util::writeLog('core', __METHOD__.', name: '.$name.' exists already', ILogger::DEBUG); |
|
370 | 370 | return false; |
371 | 371 | } |
372 | 372 | try { |
373 | 373 | $tag = new Tag($this->user, $this->type, $name); |
374 | 374 | $tag = $this->mapper->insert($tag); |
375 | 375 | $this->tags[] = $tag; |
376 | - } catch(\Exception $e) { |
|
376 | + } catch (\Exception $e) { |
|
377 | 377 | \OC::$server->getLogger()->logException($e, [ |
378 | 378 | 'message' => __METHOD__, |
379 | 379 | 'level' => ILogger::ERROR, |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | ]); |
382 | 382 | return false; |
383 | 383 | } |
384 | - \OCP\Util::writeLog('core', __METHOD__.', id: ' . $tag->getId(), ILogger::DEBUG); |
|
384 | + \OCP\Util::writeLog('core', __METHOD__.', id: '.$tag->getId(), ILogger::DEBUG); |
|
385 | 385 | return $tag->getId(); |
386 | 386 | } |
387 | 387 | |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | $from = trim($from); |
397 | 397 | $to = trim($to); |
398 | 398 | |
399 | - if($to === '' || $from === '') { |
|
399 | + if ($to === '' || $from === '') { |
|
400 | 400 | \OCP\Util::writeLog('core', __METHOD__.', Cannot use empty tag names', ILogger::DEBUG); |
401 | 401 | return false; |
402 | 402 | } |
@@ -406,21 +406,21 @@ discard block |
||
406 | 406 | } else { |
407 | 407 | $key = $this->getTagByName($from); |
408 | 408 | } |
409 | - if($key === false) { |
|
410 | - \OCP\Util::writeLog('core', __METHOD__.', tag: ' . $from. ' does not exist', ILogger::DEBUG); |
|
409 | + if ($key === false) { |
|
410 | + \OCP\Util::writeLog('core', __METHOD__.', tag: '.$from.' does not exist', ILogger::DEBUG); |
|
411 | 411 | return false; |
412 | 412 | } |
413 | 413 | $tag = $this->tags[$key]; |
414 | 414 | |
415 | - if($this->userHasTag($to, $tag->getOwner())) { |
|
416 | - \OCP\Util::writeLog('core', __METHOD__.', A tag named ' . $to. ' already exists for user ' . $tag->getOwner() . '.', ILogger::DEBUG); |
|
415 | + if ($this->userHasTag($to, $tag->getOwner())) { |
|
416 | + \OCP\Util::writeLog('core', __METHOD__.', A tag named '.$to.' already exists for user '.$tag->getOwner().'.', ILogger::DEBUG); |
|
417 | 417 | return false; |
418 | 418 | } |
419 | 419 | |
420 | 420 | try { |
421 | 421 | $tag->setName($to); |
422 | 422 | $this->tags[$key] = $this->mapper->update($tag); |
423 | - } catch(\Exception $e) { |
|
423 | + } catch (\Exception $e) { |
|
424 | 424 | \OC::$server->getLogger()->logException($e, [ |
425 | 425 | 'message' => __METHOD__, |
426 | 426 | 'level' => ILogger::ERROR, |
@@ -440,25 +440,25 @@ discard block |
||
440 | 440 | * @param int|null $id int Optional object id to add to this|these tag(s) |
441 | 441 | * @return bool Returns false on error. |
442 | 442 | */ |
443 | - public function addMultiple($names, $sync=false, $id = null) { |
|
444 | - if(!is_array($names)) { |
|
443 | + public function addMultiple($names, $sync = false, $id = null) { |
|
444 | + if (!is_array($names)) { |
|
445 | 445 | $names = [$names]; |
446 | 446 | } |
447 | 447 | $names = array_map('trim', $names); |
448 | 448 | array_filter($names); |
449 | 449 | |
450 | 450 | $newones = []; |
451 | - foreach($names as $name) { |
|
452 | - if(!$this->hasTag($name) && $name !== '') { |
|
451 | + foreach ($names as $name) { |
|
452 | + if (!$this->hasTag($name) && $name !== '') { |
|
453 | 453 | $newones[] = new Tag($this->user, $this->type, $name); |
454 | 454 | } |
455 | - if(!is_null($id) ) { |
|
455 | + if (!is_null($id)) { |
|
456 | 456 | // Insert $objectid, $categoryid pairs if not exist. |
457 | 457 | self::$relations[] = ['objid' => $id, 'tag' => $name]; |
458 | 458 | } |
459 | 459 | } |
460 | 460 | $this->tags = array_merge($this->tags, $newones); |
461 | - if($sync === true) { |
|
461 | + if ($sync === true) { |
|
462 | 462 | $this->save(); |
463 | 463 | } |
464 | 464 | |
@@ -469,13 +469,13 @@ discard block |
||
469 | 469 | * Save the list of tags and their object relations |
470 | 470 | */ |
471 | 471 | protected function save() { |
472 | - if(is_array($this->tags)) { |
|
473 | - foreach($this->tags as $tag) { |
|
472 | + if (is_array($this->tags)) { |
|
473 | + foreach ($this->tags as $tag) { |
|
474 | 474 | try { |
475 | 475 | if (!$this->mapper->tagExists($tag)) { |
476 | 476 | $this->mapper->insert($tag); |
477 | 477 | } |
478 | - } catch(\Exception $e) { |
|
478 | + } catch (\Exception $e) { |
|
479 | 479 | \OC::$server->getLogger()->logException($e, [ |
480 | 480 | 'message' => __METHOD__, |
481 | 481 | 'level' => ILogger::ERROR, |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | |
487 | 487 | // reload tags to get the proper ids. |
488 | 488 | $this->tags = $this->mapper->loadTags($this->owners, $this->type); |
489 | - \OCP\Util::writeLog('core', __METHOD__.', tags: ' . print_r($this->tags, true), |
|
489 | + \OCP\Util::writeLog('core', __METHOD__.', tags: '.print_r($this->tags, true), |
|
490 | 490 | ILogger::DEBUG); |
491 | 491 | // Loop through temporarily cached objectid/tagname pairs |
492 | 492 | // and save relations. |
@@ -494,10 +494,10 @@ discard block |
||
494 | 494 | // For some reason this is needed or array_search(i) will return 0..? |
495 | 495 | ksort($tags); |
496 | 496 | $dbConnection = \OC::$server->getDatabaseConnection(); |
497 | - foreach(self::$relations as $relation) { |
|
497 | + foreach (self::$relations as $relation) { |
|
498 | 498 | $tagId = $this->getTagId($relation['tag']); |
499 | - \OCP\Util::writeLog('core', __METHOD__ . 'catid, ' . $relation['tag'] . ' ' . $tagId, ILogger::DEBUG); |
|
500 | - if($tagId) { |
|
499 | + \OCP\Util::writeLog('core', __METHOD__.'catid, '.$relation['tag'].' '.$tagId, ILogger::DEBUG); |
|
500 | + if ($tagId) { |
|
501 | 501 | try { |
502 | 502 | $dbConnection->insertIfNotExist(self::RELATION_TABLE, |
503 | 503 | [ |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | 'categoryid' => $tagId, |
506 | 506 | 'type' => $this->type, |
507 | 507 | ]); |
508 | - } catch(\Exception $e) { |
|
508 | + } catch (\Exception $e) { |
|
509 | 509 | \OC::$server->getLogger()->logException($e, [ |
510 | 510 | 'message' => __METHOD__, |
511 | 511 | 'level' => ILogger::ERROR, |
@@ -532,13 +532,13 @@ discard block |
||
532 | 532 | // Find all objectid/tagId pairs. |
533 | 533 | $result = null; |
534 | 534 | try { |
535 | - $stmt = \OC_DB::prepare('SELECT `id` FROM `' . self::TAG_TABLE . '` ' |
|
535 | + $stmt = \OC_DB::prepare('SELECT `id` FROM `'.self::TAG_TABLE.'` ' |
|
536 | 536 | . 'WHERE `uid` = ?'); |
537 | 537 | $result = $stmt->execute([$arguments['uid']]); |
538 | 538 | if ($result === null) { |
539 | - \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
539 | + \OCP\Util::writeLog('core', __METHOD__.'DB error: '.\OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
540 | 540 | } |
541 | - } catch(\Exception $e) { |
|
541 | + } catch (\Exception $e) { |
|
542 | 542 | \OC::$server->getLogger()->logException($e, [ |
543 | 543 | 'message' => __METHOD__, |
544 | 544 | 'level' => ILogger::ERROR, |
@@ -546,14 +546,14 @@ discard block |
||
546 | 546 | ]); |
547 | 547 | } |
548 | 548 | |
549 | - if(!is_null($result)) { |
|
549 | + if (!is_null($result)) { |
|
550 | 550 | try { |
551 | - $stmt = \OC_DB::prepare('DELETE FROM `' . self::RELATION_TABLE . '` ' |
|
551 | + $stmt = \OC_DB::prepare('DELETE FROM `'.self::RELATION_TABLE.'` ' |
|
552 | 552 | . 'WHERE `categoryid` = ?'); |
553 | - while( $row = $result->fetchRow()) { |
|
553 | + while ($row = $result->fetchRow()) { |
|
554 | 554 | try { |
555 | 555 | $stmt->execute([$row['id']]); |
556 | - } catch(\Exception $e) { |
|
556 | + } catch (\Exception $e) { |
|
557 | 557 | \OC::$server->getLogger()->logException($e, [ |
558 | 558 | 'message' => __METHOD__, |
559 | 559 | 'level' => ILogger::ERROR, |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | ]); |
562 | 562 | } |
563 | 563 | } |
564 | - } catch(\Exception $e) { |
|
564 | + } catch (\Exception $e) { |
|
565 | 565 | \OC::$server->getLogger()->logException($e, [ |
566 | 566 | 'message' => __METHOD__, |
567 | 567 | 'level' => ILogger::ERROR, |
@@ -570,13 +570,13 @@ discard block |
||
570 | 570 | } |
571 | 571 | } |
572 | 572 | try { |
573 | - $stmt = \OC_DB::prepare('DELETE FROM `' . self::TAG_TABLE . '` ' |
|
573 | + $stmt = \OC_DB::prepare('DELETE FROM `'.self::TAG_TABLE.'` ' |
|
574 | 574 | . 'WHERE `uid` = ?'); |
575 | 575 | $result = $stmt->execute([$arguments['uid']]); |
576 | 576 | if ($result === null) { |
577 | - \OCP\Util::writeLog('core', __METHOD__. ', DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
577 | + \OCP\Util::writeLog('core', __METHOD__.', DB error: '.\OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
578 | 578 | } |
579 | - } catch(\Exception $e) { |
|
579 | + } catch (\Exception $e) { |
|
580 | 580 | \OC::$server->getLogger()->logException($e, [ |
581 | 581 | 'message' => __METHOD__, |
582 | 582 | 'level' => ILogger::ERROR, |
@@ -592,23 +592,23 @@ discard block |
||
592 | 592 | * @return boolean Returns false on error. |
593 | 593 | */ |
594 | 594 | public function purgeObjects(array $ids) { |
595 | - if(count($ids) === 0) { |
|
595 | + if (count($ids) === 0) { |
|
596 | 596 | // job done ;) |
597 | 597 | return true; |
598 | 598 | } |
599 | 599 | $updates = $ids; |
600 | 600 | try { |
601 | - $query = 'DELETE FROM `' . self::RELATION_TABLE . '` '; |
|
602 | - $query .= 'WHERE `objid` IN (' . str_repeat('?,', count($ids)-1) . '?) '; |
|
601 | + $query = 'DELETE FROM `'.self::RELATION_TABLE.'` '; |
|
602 | + $query .= 'WHERE `objid` IN ('.str_repeat('?,', count($ids) - 1).'?) '; |
|
603 | 603 | $query .= 'AND `type`= ?'; |
604 | 604 | $updates[] = $this->type; |
605 | 605 | $stmt = \OC_DB::prepare($query); |
606 | 606 | $result = $stmt->execute($updates); |
607 | 607 | if ($result === null) { |
608 | - \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
608 | + \OCP\Util::writeLog('core', __METHOD__.'DB error: '.\OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
609 | 609 | return false; |
610 | 610 | } |
611 | - } catch(\Exception $e) { |
|
611 | + } catch (\Exception $e) { |
|
612 | 612 | \OC::$server->getLogger()->logException($e, [ |
613 | 613 | 'message' => __METHOD__, |
614 | 614 | 'level' => ILogger::ERROR, |
@@ -625,13 +625,13 @@ discard block |
||
625 | 625 | * @return array|false An array of object ids. |
626 | 626 | */ |
627 | 627 | public function getFavorites() { |
628 | - if(!$this->userHasTag(ITags::TAG_FAVORITE, $this->user)) { |
|
628 | + if (!$this->userHasTag(ITags::TAG_FAVORITE, $this->user)) { |
|
629 | 629 | return []; |
630 | 630 | } |
631 | 631 | |
632 | 632 | try { |
633 | 633 | return $this->getIdsForTag(ITags::TAG_FAVORITE); |
634 | - } catch(\Exception $e) { |
|
634 | + } catch (\Exception $e) { |
|
635 | 635 | \OC::$server->getLogger()->logException($e, [ |
636 | 636 | 'message' => __METHOD__, |
637 | 637 | 'level' => ILogger::ERROR, |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | * @return boolean |
649 | 649 | */ |
650 | 650 | public function addToFavorites($objid) { |
651 | - if(!$this->userHasTag(ITags::TAG_FAVORITE, $this->user)) { |
|
651 | + if (!$this->userHasTag(ITags::TAG_FAVORITE, $this->user)) { |
|
652 | 652 | $this->add(ITags::TAG_FAVORITE); |
653 | 653 | } |
654 | 654 | return $this->tagAs($objid, ITags::TAG_FAVORITE); |
@@ -672,16 +672,16 @@ discard block |
||
672 | 672 | * @return boolean Returns false on error. |
673 | 673 | */ |
674 | 674 | public function tagAs($objid, $tag) { |
675 | - if(is_string($tag) && !is_numeric($tag)) { |
|
675 | + if (is_string($tag) && !is_numeric($tag)) { |
|
676 | 676 | $tag = trim($tag); |
677 | - if($tag === '') { |
|
677 | + if ($tag === '') { |
|
678 | 678 | \OCP\Util::writeLog('core', __METHOD__.', Cannot add an empty tag', ILogger::DEBUG); |
679 | 679 | return false; |
680 | 680 | } |
681 | - if(!$this->hasTag($tag)) { |
|
681 | + if (!$this->hasTag($tag)) { |
|
682 | 682 | $this->add($tag); |
683 | 683 | } |
684 | - $tagId = $this->getTagId($tag); |
|
684 | + $tagId = $this->getTagId($tag); |
|
685 | 685 | } else { |
686 | 686 | $tagId = $tag; |
687 | 687 | } |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | 'categoryid' => $tagId, |
693 | 693 | 'type' => $this->type, |
694 | 694 | ]); |
695 | - } catch(\Exception $e) { |
|
695 | + } catch (\Exception $e) { |
|
696 | 696 | \OC::$server->getLogger()->logException($e, [ |
697 | 697 | 'message' => __METHOD__, |
698 | 698 | 'level' => ILogger::ERROR, |
@@ -711,23 +711,23 @@ discard block |
||
711 | 711 | * @return boolean |
712 | 712 | */ |
713 | 713 | public function unTag($objid, $tag) { |
714 | - if(is_string($tag) && !is_numeric($tag)) { |
|
714 | + if (is_string($tag) && !is_numeric($tag)) { |
|
715 | 715 | $tag = trim($tag); |
716 | - if($tag === '') { |
|
716 | + if ($tag === '') { |
|
717 | 717 | \OCP\Util::writeLog('core', __METHOD__.', Tag name is empty', ILogger::DEBUG); |
718 | 718 | return false; |
719 | 719 | } |
720 | - $tagId = $this->getTagId($tag); |
|
720 | + $tagId = $this->getTagId($tag); |
|
721 | 721 | } else { |
722 | 722 | $tagId = $tag; |
723 | 723 | } |
724 | 724 | |
725 | 725 | try { |
726 | - $sql = 'DELETE FROM `' . self::RELATION_TABLE . '` ' |
|
726 | + $sql = 'DELETE FROM `'.self::RELATION_TABLE.'` ' |
|
727 | 727 | . 'WHERE `objid` = ? AND `categoryid` = ? AND `type` = ?'; |
728 | 728 | $stmt = \OC_DB::prepare($sql); |
729 | 729 | $stmt->execute([$objid, $tagId, $this->type]); |
730 | - } catch(\Exception $e) { |
|
730 | + } catch (\Exception $e) { |
|
731 | 731 | \OC::$server->getLogger()->logException($e, [ |
732 | 732 | 'message' => __METHOD__, |
733 | 733 | 'level' => ILogger::ERROR, |
@@ -745,16 +745,16 @@ discard block |
||
745 | 745 | * @return bool Returns false on error |
746 | 746 | */ |
747 | 747 | public function delete($names) { |
748 | - if(!is_array($names)) { |
|
748 | + if (!is_array($names)) { |
|
749 | 749 | $names = [$names]; |
750 | 750 | } |
751 | 751 | |
752 | 752 | $names = array_map('trim', $names); |
753 | 753 | array_filter($names); |
754 | 754 | |
755 | - \OCP\Util::writeLog('core', __METHOD__ . ', before: ' |
|
755 | + \OCP\Util::writeLog('core', __METHOD__.', before: ' |
|
756 | 756 | . print_r($this->tags, true), ILogger::DEBUG); |
757 | - foreach($names as $name) { |
|
757 | + foreach ($names as $name) { |
|
758 | 758 | $id = null; |
759 | 759 | |
760 | 760 | if (is_numeric($name)) { |
@@ -768,22 +768,22 @@ discard block |
||
768 | 768 | unset($this->tags[$key]); |
769 | 769 | $this->mapper->delete($tag); |
770 | 770 | } else { |
771 | - \OCP\Util::writeLog('core', __METHOD__ . 'Cannot delete tag ' . $name |
|
771 | + \OCP\Util::writeLog('core', __METHOD__.'Cannot delete tag '.$name |
|
772 | 772 | . ': not found.', ILogger::ERROR); |
773 | 773 | } |
774 | - if(!is_null($id) && $id !== false) { |
|
774 | + if (!is_null($id) && $id !== false) { |
|
775 | 775 | try { |
776 | - $sql = 'DELETE FROM `' . self::RELATION_TABLE . '` ' |
|
776 | + $sql = 'DELETE FROM `'.self::RELATION_TABLE.'` ' |
|
777 | 777 | . 'WHERE `categoryid` = ?'; |
778 | 778 | $stmt = \OC_DB::prepare($sql); |
779 | 779 | $result = $stmt->execute([$id]); |
780 | 780 | if ($result === null) { |
781 | 781 | \OCP\Util::writeLog('core', |
782 | - __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), |
|
782 | + __METHOD__.'DB error: '.\OC::$server->getDatabaseConnection()->getError(), |
|
783 | 783 | ILogger::ERROR); |
784 | 784 | return false; |
785 | 785 | } |
786 | - } catch(\Exception $e) { |
|
786 | + } catch (\Exception $e) { |
|
787 | 787 | \OC::$server->getLogger()->logException($e, [ |
788 | 788 | 'message' => __METHOD__, |
789 | 789 | 'level' => ILogger::ERROR, |
@@ -797,12 +797,12 @@ discard block |
||
797 | 797 | } |
798 | 798 | |
799 | 799 | // case-insensitive array_search |
800 | - protected function array_searchi($needle, $haystack, $mem='getName') { |
|
801 | - if(!is_array($haystack)) { |
|
800 | + protected function array_searchi($needle, $haystack, $mem = 'getName') { |
|
801 | + if (!is_array($haystack)) { |
|
802 | 802 | return false; |
803 | 803 | } |
804 | 804 | return array_search(strtolower($needle), array_map( |
805 | - function ($tag) use ($mem) { |
|
805 | + function($tag) use ($mem) { |
|
806 | 806 | return strtolower(call_user_func([$tag, $mem])); |
807 | 807 | }, $haystack) |
808 | 808 | ); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | return; |
174 | 174 | } |
175 | 175 | |
176 | - $this->dispatcher->dispatch(IGroup::class . '::preAddUser', new GenericEvent($this, [ |
|
176 | + $this->dispatcher->dispatch(IGroup::class.'::preAddUser', new GenericEvent($this, [ |
|
177 | 177 | 'user' => $user, |
178 | 178 | ])); |
179 | 179 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | $this->users[$user->getUID()] = $user; |
188 | 188 | } |
189 | 189 | |
190 | - $this->dispatcher->dispatch(IGroup::class . '::postAddUser', new GenericEvent($this, [ |
|
190 | + $this->dispatcher->dispatch(IGroup::class.'::postAddUser', new GenericEvent($this, [ |
|
191 | 191 | 'user' => $user, |
192 | 192 | ])); |
193 | 193 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | public function removeUser($user) { |
208 | 208 | $result = false; |
209 | - $this->dispatcher->dispatch(IGroup::class . '::preRemoveUser', new GenericEvent($this, [ |
|
209 | + $this->dispatcher->dispatch(IGroup::class.'::preRemoveUser', new GenericEvent($this, [ |
|
210 | 210 | 'user' => $user, |
211 | 211 | ])); |
212 | 212 | if ($this->emitter) { |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | } |
220 | 220 | } |
221 | 221 | if ($result) { |
222 | - $this->dispatcher->dispatch(IGroup::class . '::postRemoveUser', new GenericEvent($this, [ |
|
222 | + $this->dispatcher->dispatch(IGroup::class.'::postRemoveUser', new GenericEvent($this, [ |
|
223 | 223 | 'user' => $user, |
224 | 224 | ])); |
225 | 225 | if ($this->emitter) { |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | public function count($search = '') { |
266 | 266 | $users = false; |
267 | 267 | foreach ($this->backends as $backend) { |
268 | - if($backend->implementsActions(\OC\Group\Backend::COUNT_USERS)) { |
|
269 | - if($users === false) { |
|
268 | + if ($backend->implementsActions(\OC\Group\Backend::COUNT_USERS)) { |
|
269 | + if ($users === false) { |
|
270 | 270 | //we could directly add to a bool variable, but this would |
271 | 271 | //be ugly |
272 | 272 | $users = 0; |
@@ -285,8 +285,8 @@ discard block |
||
285 | 285 | public function countDisabled() { |
286 | 286 | $users = false; |
287 | 287 | foreach ($this->backends as $backend) { |
288 | - if($backend instanceOf ICountDisabledInGroup) { |
|
289 | - if($users === false) { |
|
288 | + if ($backend instanceOf ICountDisabledInGroup) { |
|
289 | + if ($users === false) { |
|
290 | 290 | //we could directly add to a bool variable, but this would |
291 | 291 | //be ugly |
292 | 292 | $users = 0; |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | } |
330 | 330 | |
331 | 331 | $result = false; |
332 | - $this->dispatcher->dispatch(IGroup::class . '::preDelete', new GenericEvent($this)); |
|
332 | + $this->dispatcher->dispatch(IGroup::class.'::preDelete', new GenericEvent($this)); |
|
333 | 333 | if ($this->emitter) { |
334 | 334 | $this->emitter->emit('\OC\Group', 'preDelete', [$this]); |
335 | 335 | } |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | } |
341 | 341 | } |
342 | 342 | if ($result) { |
343 | - $this->dispatcher->dispatch(IGroup::class . '::postDelete', new GenericEvent($this)); |
|
343 | + $this->dispatcher->dispatch(IGroup::class.'::postDelete', new GenericEvent($this)); |
|
344 | 344 | if ($this->emitter) { |
345 | 345 | $this->emitter->emit('\OC\Group', 'postDelete', [$this]); |
346 | 346 | } |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | * @since 16.0.0 |
399 | 399 | */ |
400 | 400 | public function hideFromCollaboration(): bool { |
401 | - return array_reduce($this->backends, function (bool $hide, GroupInterface $backend) { |
|
401 | + return array_reduce($this->backends, function(bool $hide, GroupInterface $backend) { |
|
402 | 402 | return $hide | ($backend instanceof IHideFromCollaborationBackend && $backend->hideGroup($this->gid)); |
403 | 403 | }, false); |
404 | 404 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | ->setValue('gid', $builder->createNamedParameter($gid)) |
114 | 114 | ->setValue('displayname', $builder->createNamedParameter($gid)) |
115 | 115 | ->execute(); |
116 | - } catch(UniqueConstraintViolationException $e) { |
|
116 | + } catch (UniqueConstraintViolationException $e) { |
|
117 | 117 | $result = 0; |
118 | 118 | } |
119 | 119 | |
@@ -194,14 +194,14 @@ discard block |
||
194 | 194 | $this->fixDI(); |
195 | 195 | |
196 | 196 | // No duplicate entries! |
197 | - if( !$this->inGroup( $uid, $gid )) { |
|
197 | + if (!$this->inGroup($uid, $gid)) { |
|
198 | 198 | $qb = $this->dbConn->getQueryBuilder(); |
199 | 199 | $qb->insert('group_user') |
200 | 200 | ->setValue('uid', $qb->createNamedParameter($uid)) |
201 | 201 | ->setValue('gid', $qb->createNamedParameter($gid)) |
202 | 202 | ->execute(); |
203 | 203 | return true; |
204 | - }else{ |
|
204 | + } else { |
|
205 | 205 | return false; |
206 | 206 | } |
207 | 207 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | ->execute(); |
251 | 251 | |
252 | 252 | $groups = []; |
253 | - while( $row = $cursor->fetch()) { |
|
253 | + while ($row = $cursor->fetch()) { |
|
254 | 254 | $groups[] = $row['gid']; |
255 | 255 | $this->groupCache[$row['gid']] = $row['gid']; |
256 | 256 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | |
279 | 279 | if ($search !== '') { |
280 | 280 | $query->where($query->expr()->iLike('gid', $query->createNamedParameter( |
281 | - '%' . $this->dbConn->escapeLikeParameter($search) . '%' |
|
281 | + '%'.$this->dbConn->escapeLikeParameter($search).'%' |
|
282 | 282 | ))); |
283 | 283 | } |
284 | 284 | |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | |
343 | 343 | if ($search !== '') { |
344 | 344 | $query->andWhere($query->expr()->like('uid', $query->createNamedParameter( |
345 | - '%' . $this->dbConn->escapeLikeParameter($search) . '%' |
|
345 | + '%'.$this->dbConn->escapeLikeParameter($search).'%' |
|
346 | 346 | ))); |
347 | 347 | } |
348 | 348 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | |
381 | 381 | if ($search !== '') { |
382 | 382 | $query->andWhere($query->expr()->like('uid', $query->createNamedParameter( |
383 | - '%' . $this->dbConn->escapeLikeParameter($search) . '%' |
|
383 | + '%'.$this->dbConn->escapeLikeParameter($search).'%' |
|
384 | 384 | ))); |
385 | 385 | } |
386 | 386 | |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | $result->closeCursor(); |
390 | 390 | |
391 | 391 | if ($count !== false) { |
392 | - $count = (int)$count; |
|
392 | + $count = (int) $count; |
|
393 | 393 | } else { |
394 | 394 | $count = 0; |
395 | 395 | } |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | $this->fixDI(); |
409 | 409 | |
410 | 410 | $query = $this->dbConn->getQueryBuilder(); |
411 | - $query->select($query->createFunction('COUNT(DISTINCT ' . $query->getColumnName('uid') . ')')) |
|
411 | + $query->select($query->createFunction('COUNT(DISTINCT '.$query->getColumnName('uid').')')) |
|
412 | 412 | ->from('preferences', 'p') |
413 | 413 | ->innerJoin('p', 'group_user', 'g', $query->expr()->eq('p.userid', 'g.uid')) |
414 | 414 | ->where($query->expr()->eq('appid', $query->createNamedParameter('core'))) |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | $result->closeCursor(); |
422 | 422 | |
423 | 423 | if ($count !== false) { |
424 | - $count = (int)$count; |
|
424 | + $count = (int) $count; |
|
425 | 425 | } else { |
426 | 426 | $count = 0; |
427 | 427 | } |