@@ -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 | /** |
@@ -33,6 +33,6 @@ |
||
| 33 | 33 | * @inheritdoc |
| 34 | 34 | */ |
| 35 | 35 | public function like($x, $y, $type = null) { |
| 36 | - return parent::like($x, $y, $type) . " ESCAPE '\\'"; |
|
| 36 | + return parent::like($x, $y, $type)." ESCAPE '\\'"; |
|
| 37 | 37 | } |
| 38 | 38 | } |
@@ -25,6 +25,6 @@ |
||
| 25 | 25 | |
| 26 | 26 | class OCIFunctionBuilder extends FunctionBuilder { |
| 27 | 27 | public function md5($input) { |
| 28 | - return new QueryFunction('LOWER(DBMS_OBFUSCATION_TOOLKIT.md5 (input => UTL_RAW.cast_to_raw(' . $this->helper->quoteColumnName($input) .')))'); |
|
| 28 | + return new QueryFunction('LOWER(DBMS_OBFUSCATION_TOOLKIT.md5 (input => UTL_RAW.cast_to_raw('.$this->helper->quoteColumnName($input).')))'); |
|
| 29 | 29 | } |
| 30 | 30 | } |
@@ -39,18 +39,18 @@ |
||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function md5($input) { |
| 42 | - return new QueryFunction('MD5(' . $this->helper->quoteColumnName($input) . ')'); |
|
| 42 | + return new QueryFunction('MD5('.$this->helper->quoteColumnName($input).')'); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | public function concat($x, $y) { |
| 46 | - return new QueryFunction('CONCAT(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 46 | + return new QueryFunction('CONCAT('.$this->helper->quoteColumnName($x).', '.$this->helper->quoteColumnName($y).')'); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | public function substring($input, $start, $length = null) { |
| 50 | 50 | if ($length) { |
| 51 | - return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ', ' . $this->helper->quoteColumnName($length) . ')'); |
|
| 51 | + return new QueryFunction('SUBSTR('.$this->helper->quoteColumnName($input).', '.$this->helper->quoteColumnName($start).', '.$this->helper->quoteColumnName($length).')'); |
|
| 52 | 52 | } else { |
| 53 | - return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ')'); |
|
| 53 | + return new QueryFunction('SUBSTR('.$this->helper->quoteColumnName($input).', '.$this->helper->quoteColumnName($start).')'); |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | } |
@@ -25,6 +25,6 @@ |
||
| 25 | 25 | |
| 26 | 26 | class SqliteFunctionBuilder 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 | } |
@@ -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 | } |
@@ -56,8 +56,8 @@ |
||
| 56 | 56 | */ |
| 57 | 57 | public function postConnect(ConnectionEventArgs $args) { |
| 58 | 58 | $sensitive = ($this->caseSensitiveLike) ? 'true' : 'false'; |
| 59 | - $args->getConnection()->executeUpdate('PRAGMA case_sensitive_like = ' . $sensitive); |
|
| 60 | - $args->getConnection()->executeUpdate('PRAGMA journal_mode = ' . $this->journalMode); |
|
| 59 | + $args->getConnection()->executeUpdate('PRAGMA case_sensitive_like = '.$sensitive); |
|
| 60 | + $args->getConnection()->executeUpdate('PRAGMA journal_mode = '.$this->journalMode); |
|
| 61 | 61 | /** @var \PDO $pdo */ |
| 62 | 62 | $pdo = $args->getConnection()->getWrappedConnection(); |
| 63 | 63 | $pdo->sqliteCreateFunction('md5', 'md5', 1); |
@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | public function fixupStatement($statement) { |
| 44 | 44 | $statement = preg_replace('/`(\w+)` ILIKE \?/', 'LOWER($1) LIKE LOWER(?)', $statement); |
| 45 | - $statement = str_replace( '`', '"', $statement ); |
|
| 46 | - $statement = str_ireplace( 'NOW()', 'datetime(\'now\')', $statement ); |
|
| 45 | + $statement = str_replace('`', '"', $statement); |
|
| 46 | + $statement = str_ireplace('NOW()', 'datetime(\'now\')', $statement); |
|
| 47 | 47 | $statement = str_ireplace('GREATEST(', 'MAX(', $statement); |
| 48 | - $statement = str_ireplace( 'UNIX_TIMESTAMP()', 'strftime(\'%s\',\'now\')', $statement ); |
|
| 48 | + $statement = str_ireplace('UNIX_TIMESTAMP()', 'strftime(\'%s\',\'now\')', $statement); |
|
| 49 | 49 | return $statement; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -64,14 +64,14 @@ discard block |
||
| 64 | 64 | if (empty($compare)) { |
| 65 | 65 | $compare = array_keys($input); |
| 66 | 66 | } |
| 67 | - $fieldList = '`' . implode('`,`', array_keys($input)) . '`'; |
|
| 67 | + $fieldList = '`'.implode('`,`', array_keys($input)).'`'; |
|
| 68 | 68 | $query = "INSERT INTO `$table` ($fieldList) SELECT " |
| 69 | - . str_repeat('?,', count($input)-1).'? ' |
|
| 69 | + . str_repeat('?,', count($input) - 1).'? ' |
|
| 70 | 70 | . " WHERE NOT EXISTS (SELECT 1 FROM `$table` WHERE "; |
| 71 | 71 | |
| 72 | 72 | $inserts = array_values($input); |
| 73 | - foreach($compare as $key) { |
|
| 74 | - $query .= '`' . $key . '`'; |
|
| 73 | + foreach ($compare as $key) { |
|
| 74 | + $query .= '`'.$key.'`'; |
|
| 75 | 75 | if (is_null($input[$key])) { |
| 76 | 76 | $query .= ' IS NULL AND '; |
| 77 | 77 | } else { |
@@ -163,21 +163,21 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | public static function cacheEntryFromData($data, IMimeTypeLoader $mimetypeLoader) { |
| 165 | 165 | //fix types |
| 166 | - $data['fileid'] = (int)$data['fileid']; |
|
| 167 | - $data['parent'] = (int)$data['parent']; |
|
| 166 | + $data['fileid'] = (int) $data['fileid']; |
|
| 167 | + $data['parent'] = (int) $data['parent']; |
|
| 168 | 168 | $data['size'] = 0 + $data['size']; |
| 169 | - $data['mtime'] = (int)$data['mtime']; |
|
| 170 | - $data['storage_mtime'] = (int)$data['storage_mtime']; |
|
| 171 | - $data['encryptedVersion'] = (int)$data['encrypted']; |
|
| 172 | - $data['encrypted'] = (bool)$data['encrypted']; |
|
| 169 | + $data['mtime'] = (int) $data['mtime']; |
|
| 170 | + $data['storage_mtime'] = (int) $data['storage_mtime']; |
|
| 171 | + $data['encryptedVersion'] = (int) $data['encrypted']; |
|
| 172 | + $data['encrypted'] = (bool) $data['encrypted']; |
|
| 173 | 173 | $data['storage_id'] = $data['storage']; |
| 174 | - $data['storage'] = (int)$data['storage']; |
|
| 174 | + $data['storage'] = (int) $data['storage']; |
|
| 175 | 175 | $data['mimetype'] = $mimetypeLoader->getMimetypeById($data['mimetype']); |
| 176 | 176 | $data['mimepart'] = $mimetypeLoader->getMimetypeById($data['mimepart']); |
| 177 | 177 | if ($data['storage_mtime'] == 0) { |
| 178 | 178 | $data['storage_mtime'] = $data['mtime']; |
| 179 | 179 | } |
| 180 | - $data['permissions'] = (int)$data['permissions']; |
|
| 180 | + $data['permissions'] = (int) $data['permissions']; |
|
| 181 | 181 | return new CacheEntry($data); |
| 182 | 182 | } |
| 183 | 183 | |
@@ -205,8 +205,8 @@ discard block |
||
| 205 | 205 | FROM `*PREFIX*filecache` WHERE `parent` = ? ORDER BY `name` ASC'; |
| 206 | 206 | $result = $this->connection->executeQuery($sql, [$fileId]); |
| 207 | 207 | $files = $result->fetchAll(); |
| 208 | - return array_map(function (array $data) { |
|
| 209 | - return self::cacheEntryFromData($data, $this->mimetypeLoader);; |
|
| 208 | + return array_map(function(array $data) { |
|
| 209 | + return self::cacheEntryFromData($data, $this->mimetypeLoader); ; |
|
| 210 | 210 | }, $files); |
| 211 | 211 | } else { |
| 212 | 212 | return array(); |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | $queryParts[] = '`storage`'; |
| 266 | 266 | $params[] = $this->getNumericStorageId(); |
| 267 | 267 | |
| 268 | - $queryParts = array_map(function ($item) { |
|
| 268 | + $queryParts = array_map(function($item) { |
|
| 269 | 269 | return trim($item, "`"); |
| 270 | 270 | }, $queryParts); |
| 271 | 271 | $values = array_combine($queryParts, $params); |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | 'path_hash', |
| 275 | 275 | ]) |
| 276 | 276 | ) { |
| 277 | - return (int)$this->connection->lastInsertId('*PREFIX*filecache'); |
|
| 277 | + return (int) $this->connection->lastInsertId('*PREFIX*filecache'); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | // The file was created in the mean time |
@@ -312,10 +312,10 @@ discard block |
||
| 312 | 312 | |
| 313 | 313 | // don't update if the data we try to set is the same as the one in the record |
| 314 | 314 | // some databases (Postgres) don't like superfluous updates |
| 315 | - $sql = 'UPDATE `*PREFIX*filecache` SET ' . implode(' = ?, ', $queryParts) . '=? ' . |
|
| 316 | - 'WHERE (' . |
|
| 317 | - implode(' <> ? OR ', $queryParts) . ' <> ? OR ' . |
|
| 318 | - implode(' IS NULL OR ', $queryParts) . ' IS NULL' . |
|
| 315 | + $sql = 'UPDATE `*PREFIX*filecache` SET '.implode(' = ?, ', $queryParts).'=? '. |
|
| 316 | + 'WHERE ('. |
|
| 317 | + implode(' <> ? OR ', $queryParts).' <> ? OR '. |
|
| 318 | + implode(' IS NULL OR ', $queryParts).' IS NULL'. |
|
| 319 | 319 | ') AND `fileid` = ? '; |
| 320 | 320 | $this->connection->executeQuery($sql, $params); |
| 321 | 321 | |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | } |
| 367 | 367 | } |
| 368 | 368 | $params[] = $value; |
| 369 | - $queryParts[] = '`' . $name . '`'; |
|
| 369 | + $queryParts[] = '`'.$name.'`'; |
|
| 370 | 370 | } |
| 371 | 371 | } |
| 372 | 372 | return array($queryParts, $params); |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | return -1; |
| 409 | 409 | } else { |
| 410 | 410 | $parent = $this->getParentPath($file); |
| 411 | - return (int)$this->getId($parent); |
|
| 411 | + return (int) $this->getId($parent); |
|
| 412 | 412 | } |
| 413 | 413 | } |
| 414 | 414 | |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | */ |
| 455 | 455 | private function getSubFolders($entry) { |
| 456 | 456 | $children = $this->getFolderContentsById($entry['fileid']); |
| 457 | - return array_filter($children, function ($child) { |
|
| 457 | + return array_filter($children, function($child) { |
|
| 458 | 458 | return $child['mimetype'] === 'httpd/unix-directory'; |
| 459 | 459 | }); |
| 460 | 460 | } |
@@ -517,10 +517,10 @@ discard block |
||
| 517 | 517 | list($targetStorageId, $targetPath) = $this->getMoveInfo($targetPath); |
| 518 | 518 | |
| 519 | 519 | if (is_null($sourceStorageId) || $sourceStorageId === false) { |
| 520 | - throw new \Exception('Invalid source storage id: ' . $sourceStorageId); |
|
| 520 | + throw new \Exception('Invalid source storage id: '.$sourceStorageId); |
|
| 521 | 521 | } |
| 522 | 522 | if (is_null($targetStorageId) || $targetStorageId === false) { |
| 523 | - throw new \Exception('Invalid target storage id: ' . $targetStorageId); |
|
| 523 | + throw new \Exception('Invalid target storage id: '.$targetStorageId); |
|
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | $this->connection->beginTransaction(); |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | ->set('path_hash', $fun->md5($newPathFunction)) |
| 540 | 540 | ->set('path', $newPathFunction) |
| 541 | 541 | ->where($query->expr()->eq('storage', $query->createNamedParameter($sourceStorageId, IQueryBuilder::PARAM_INT))) |
| 542 | - ->andWhere($query->expr()->like('path', $query->createNamedParameter($this->connection->escapeLikeParameter($sourcePath) . '/%'))); |
|
| 542 | + ->andWhere($query->expr()->like('path', $query->createNamedParameter($this->connection->escapeLikeParameter($sourcePath).'/%'))); |
|
| 543 | 543 | |
| 544 | 544 | try { |
| 545 | 545 | $query->execute(); |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | $sql = 'SELECT `size` FROM `*PREFIX*filecache` WHERE `storage` = ? AND `path_hash` = ?'; |
| 589 | 589 | $result = $this->connection->executeQuery($sql, array($this->getNumericStorageId(), $pathHash)); |
| 590 | 590 | if ($row = $result->fetch()) { |
| 591 | - if ((int)$row['size'] === -1) { |
|
| 591 | + if ((int) $row['size'] === -1) { |
|
| 592 | 592 | return self::SHALLOW; |
| 593 | 593 | } else { |
| 594 | 594 | return self::COMPLETE; |
@@ -637,7 +637,7 @@ discard block |
||
| 637 | 637 | private function searchResultToCacheEntries(Statement $result) { |
| 638 | 638 | $files = $result->fetchAll(); |
| 639 | 639 | |
| 640 | - return array_map(function (array $data) { |
|
| 640 | + return array_map(function(array $data) { |
|
| 641 | 641 | return self::cacheEntryFromData($data, $this->mimetypeLoader); |
| 642 | 642 | }, $files); |
| 643 | 643 | } |
@@ -656,7 +656,7 @@ discard block |
||
| 656 | 656 | $where = '`mimepart` = ?'; |
| 657 | 657 | } |
| 658 | 658 | $sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `storage_mtime`, `mtime`, `encrypted`, `etag`, `permissions`, `checksum` |
| 659 | - FROM `*PREFIX*filecache` WHERE ' . $where . ' AND `storage` = ?'; |
|
| 659 | + FROM `*PREFIX*filecache` WHERE ' . $where.' AND `storage` = ?'; |
|
| 660 | 660 | $mimetype = $this->mimetypeLoader->getId($mimetype); |
| 661 | 661 | $result = $this->connection->executeQuery($sql, array($mimetype, $this->getNumericStorageId())); |
| 662 | 662 | |
@@ -707,20 +707,20 @@ discard block |
||
| 707 | 707 | * @return ICacheEntry[] file data |
| 708 | 708 | */ |
| 709 | 709 | public function searchByTag($tag, $userId) { |
| 710 | - $sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, ' . |
|
| 711 | - '`mimetype`, `mimepart`, `size`, `mtime`, `storage_mtime`, ' . |
|
| 712 | - '`encrypted`, `etag`, `permissions`, `checksum` ' . |
|
| 713 | - 'FROM `*PREFIX*filecache` `file`, ' . |
|
| 714 | - '`*PREFIX*vcategory_to_object` `tagmap`, ' . |
|
| 715 | - '`*PREFIX*vcategory` `tag` ' . |
|
| 710 | + $sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, '. |
|
| 711 | + '`mimetype`, `mimepart`, `size`, `mtime`, `storage_mtime`, '. |
|
| 712 | + '`encrypted`, `etag`, `permissions`, `checksum` '. |
|
| 713 | + 'FROM `*PREFIX*filecache` `file`, '. |
|
| 714 | + '`*PREFIX*vcategory_to_object` `tagmap`, '. |
|
| 715 | + '`*PREFIX*vcategory` `tag` '. |
|
| 716 | 716 | // JOIN filecache to vcategory_to_object |
| 717 | - 'WHERE `file`.`fileid` = `tagmap`.`objid` ' . |
|
| 717 | + 'WHERE `file`.`fileid` = `tagmap`.`objid` '. |
|
| 718 | 718 | // JOIN vcategory_to_object to vcategory |
| 719 | - 'AND `tagmap`.`type` = `tag`.`type` ' . |
|
| 720 | - 'AND `tagmap`.`categoryid` = `tag`.`id` ' . |
|
| 719 | + 'AND `tagmap`.`type` = `tag`.`type` '. |
|
| 720 | + 'AND `tagmap`.`categoryid` = `tag`.`id` '. |
|
| 721 | 721 | // conditions |
| 722 | - 'AND `file`.`storage` = ? ' . |
|
| 723 | - 'AND `tag`.`type` = \'files\' ' . |
|
| 722 | + 'AND `file`.`storage` = ? '. |
|
| 723 | + 'AND `tag`.`type` = \'files\' '. |
|
| 724 | 724 | 'AND `tag`.`uid` = ? '; |
| 725 | 725 | if (is_int($tag)) { |
| 726 | 726 | $sql .= 'AND `tag`.`id` = ? '; |
@@ -738,7 +738,7 @@ discard block |
||
| 738 | 738 | |
| 739 | 739 | $files = $result->fetchAll(); |
| 740 | 740 | |
| 741 | - return array_map(function (array $data) { |
|
| 741 | + return array_map(function(array $data) { |
|
| 742 | 742 | return self::cacheEntryFromData($data, $this->mimetypeLoader); |
| 743 | 743 | }, $files); |
| 744 | 744 | } |
@@ -774,8 +774,8 @@ discard block |
||
| 774 | 774 | } |
| 775 | 775 | if (isset($entry['mimetype']) && $entry['mimetype'] === 'httpd/unix-directory') { |
| 776 | 776 | $id = $entry['fileid']; |
| 777 | - $sql = 'SELECT SUM(`size`) AS f1, MIN(`size`) AS f2 ' . |
|
| 778 | - 'FROM `*PREFIX*filecache` ' . |
|
| 777 | + $sql = 'SELECT SUM(`size`) AS f1, MIN(`size`) AS f2 '. |
|
| 778 | + 'FROM `*PREFIX*filecache` '. |
|
| 779 | 779 | 'WHERE `parent` = ? AND `storage` = ?'; |
| 780 | 780 | $result = $this->connection->executeQuery($sql, array($id, $this->getNumericStorageId())); |
| 781 | 781 | if ($row = $result->fetch()) { |