@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | ->setValue('lock', $builder->createNamedParameter($lock)) |
| 126 | 126 | ->setValue('ttl', $builder->createNamedParameter($expire)) |
| 127 | 127 | ->execute(); |
| 128 | - } catch(UniqueConstraintViolationException $e) { |
|
| 128 | + } catch (UniqueConstraintViolationException $e) { |
|
| 129 | 129 | return 0; |
| 130 | 130 | } |
| 131 | 131 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | } |
| 149 | 149 | $query = $this->connection->prepare('SELECT `lock` from `*PREFIX*file_locks` WHERE `key` = ?'); |
| 150 | 150 | $query->execute([$path]); |
| 151 | - $lockValue = (int)$query->fetchColumn(); |
|
| 151 | + $lockValue = (int) $query->fetchColumn(); |
|
| 152 | 152 | if ($type === self::LOCK_SHARED) { |
| 153 | 153 | if ($this->isLocallyLocked($path)) { |
| 154 | 154 | // if we have a shared lock we kept open locally but it's released we always have at least 1 shared lock in the db |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | |
| 275 | 275 | // since we keep shared locks we need to manually clean those |
| 276 | 276 | $lockedPaths = array_keys($this->sharedLocks); |
| 277 | - $lockedPaths = array_filter($lockedPaths, function ($path) { |
|
| 277 | + $lockedPaths = array_filter($lockedPaths, function($path) { |
|
| 278 | 278 | return $this->sharedLocks[$path]; |
| 279 | 279 | }); |
| 280 | 280 | |
@@ -164,21 +164,21 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | public static function cacheEntryFromData($data, IMimeTypeLoader $mimetypeLoader) { |
| 166 | 166 | //fix types |
| 167 | - $data['fileid'] = (int)$data['fileid']; |
|
| 168 | - $data['parent'] = (int)$data['parent']; |
|
| 167 | + $data['fileid'] = (int) $data['fileid']; |
|
| 168 | + $data['parent'] = (int) $data['parent']; |
|
| 169 | 169 | $data['size'] = 0 + $data['size']; |
| 170 | - $data['mtime'] = (int)$data['mtime']; |
|
| 171 | - $data['storage_mtime'] = (int)$data['storage_mtime']; |
|
| 172 | - $data['encryptedVersion'] = (int)$data['encrypted']; |
|
| 173 | - $data['encrypted'] = (bool)$data['encrypted']; |
|
| 170 | + $data['mtime'] = (int) $data['mtime']; |
|
| 171 | + $data['storage_mtime'] = (int) $data['storage_mtime']; |
|
| 172 | + $data['encryptedVersion'] = (int) $data['encrypted']; |
|
| 173 | + $data['encrypted'] = (bool) $data['encrypted']; |
|
| 174 | 174 | $data['storage_id'] = $data['storage']; |
| 175 | - $data['storage'] = (int)$data['storage']; |
|
| 175 | + $data['storage'] = (int) $data['storage']; |
|
| 176 | 176 | $data['mimetype'] = $mimetypeLoader->getMimetypeById($data['mimetype']); |
| 177 | 177 | $data['mimepart'] = $mimetypeLoader->getMimetypeById($data['mimepart']); |
| 178 | 178 | if ($data['storage_mtime'] == 0) { |
| 179 | 179 | $data['storage_mtime'] = $data['mtime']; |
| 180 | 180 | } |
| 181 | - $data['permissions'] = (int)$data['permissions']; |
|
| 181 | + $data['permissions'] = (int) $data['permissions']; |
|
| 182 | 182 | return new CacheEntry($data); |
| 183 | 183 | } |
| 184 | 184 | |
@@ -206,8 +206,8 @@ discard block |
||
| 206 | 206 | FROM `*PREFIX*filecache` WHERE `parent` = ? ORDER BY `name` ASC'; |
| 207 | 207 | $result = $this->connection->executeQuery($sql, [$fileId]); |
| 208 | 208 | $files = $result->fetchAll(); |
| 209 | - return array_map(function (array $data) { |
|
| 210 | - return self::cacheEntryFromData($data, $this->mimetypeLoader);; |
|
| 209 | + return array_map(function(array $data) { |
|
| 210 | + return self::cacheEntryFromData($data, $this->mimetypeLoader); ; |
|
| 211 | 211 | }, $files); |
| 212 | 212 | } else { |
| 213 | 213 | return array(); |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | $queryParts[] = '`storage`'; |
| 269 | 269 | $params[] = $this->getNumericStorageId(); |
| 270 | 270 | |
| 271 | - $queryParts = array_map(function ($item) { |
|
| 271 | + $queryParts = array_map(function($item) { |
|
| 272 | 272 | return trim($item, "`"); |
| 273 | 273 | }, $queryParts); |
| 274 | 274 | $values = array_combine($queryParts, $params); |
@@ -282,9 +282,9 @@ discard block |
||
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | if ($builder->execute()) { |
| 285 | - return (int)$this->connection->lastInsertId('*PREFIX*filecache'); |
|
| 285 | + return (int) $this->connection->lastInsertId('*PREFIX*filecache'); |
|
| 286 | 286 | } |
| 287 | - } catch(UniqueConstraintViolationException $e) { |
|
| 287 | + } catch (UniqueConstraintViolationException $e) { |
|
| 288 | 288 | // entry exists already |
| 289 | 289 | } |
| 290 | 290 | |
@@ -323,10 +323,10 @@ discard block |
||
| 323 | 323 | |
| 324 | 324 | // don't update if the data we try to set is the same as the one in the record |
| 325 | 325 | // some databases (Postgres) don't like superfluous updates |
| 326 | - $sql = 'UPDATE `*PREFIX*filecache` SET ' . implode(' = ?, ', $queryParts) . '=? ' . |
|
| 327 | - 'WHERE (' . |
|
| 328 | - implode(' <> ? OR ', $queryParts) . ' <> ? OR ' . |
|
| 329 | - implode(' IS NULL OR ', $queryParts) . ' IS NULL' . |
|
| 326 | + $sql = 'UPDATE `*PREFIX*filecache` SET '.implode(' = ?, ', $queryParts).'=? '. |
|
| 327 | + 'WHERE ('. |
|
| 328 | + implode(' <> ? OR ', $queryParts).' <> ? OR '. |
|
| 329 | + implode(' IS NULL OR ', $queryParts).' IS NULL'. |
|
| 330 | 330 | ') AND `fileid` = ? '; |
| 331 | 331 | $this->connection->executeQuery($sql, $params); |
| 332 | 332 | |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | } |
| 378 | 378 | } |
| 379 | 379 | $params[] = $value; |
| 380 | - $queryParts[] = '`' . $name . '`'; |
|
| 380 | + $queryParts[] = '`'.$name.'`'; |
|
| 381 | 381 | } |
| 382 | 382 | } |
| 383 | 383 | return array($queryParts, $params); |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | return -1; |
| 420 | 420 | } else { |
| 421 | 421 | $parent = $this->getParentPath($file); |
| 422 | - return (int)$this->getId($parent); |
|
| 422 | + return (int) $this->getId($parent); |
|
| 423 | 423 | } |
| 424 | 424 | } |
| 425 | 425 | |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | */ |
| 466 | 466 | private function getSubFolders($entry) { |
| 467 | 467 | $children = $this->getFolderContentsById($entry['fileid']); |
| 468 | - return array_filter($children, function ($child) { |
|
| 468 | + return array_filter($children, function($child) { |
|
| 469 | 469 | return $child['mimetype'] === 'httpd/unix-directory'; |
| 470 | 470 | }); |
| 471 | 471 | } |
@@ -529,10 +529,10 @@ discard block |
||
| 529 | 529 | list($targetStorageId, $targetPath) = $this->getMoveInfo($targetPath); |
| 530 | 530 | |
| 531 | 531 | if (is_null($sourceStorageId) || $sourceStorageId === false) { |
| 532 | - throw new \Exception('Invalid source storage id: ' . $sourceStorageId); |
|
| 532 | + throw new \Exception('Invalid source storage id: '.$sourceStorageId); |
|
| 533 | 533 | } |
| 534 | 534 | if (is_null($targetStorageId) || $targetStorageId === false) { |
| 535 | - throw new \Exception('Invalid target storage id: ' . $targetStorageId); |
|
| 535 | + throw new \Exception('Invalid target storage id: '.$targetStorageId); |
|
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | $this->connection->beginTransaction(); |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | ->set('path_hash', $fun->md5($newPathFunction)) |
| 552 | 552 | ->set('path', $newPathFunction) |
| 553 | 553 | ->where($query->expr()->eq('storage', $query->createNamedParameter($sourceStorageId, IQueryBuilder::PARAM_INT))) |
| 554 | - ->andWhere($query->expr()->like('path', $query->createNamedParameter($this->connection->escapeLikeParameter($sourcePath) . '/%'))); |
|
| 554 | + ->andWhere($query->expr()->like('path', $query->createNamedParameter($this->connection->escapeLikeParameter($sourcePath).'/%'))); |
|
| 555 | 555 | |
| 556 | 556 | try { |
| 557 | 557 | $query->execute(); |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | $sql = 'SELECT `size` FROM `*PREFIX*filecache` WHERE `storage` = ? AND `path_hash` = ?'; |
| 601 | 601 | $result = $this->connection->executeQuery($sql, array($this->getNumericStorageId(), $pathHash)); |
| 602 | 602 | if ($row = $result->fetch()) { |
| 603 | - if ((int)$row['size'] === -1) { |
|
| 603 | + if ((int) $row['size'] === -1) { |
|
| 604 | 604 | return self::SHALLOW; |
| 605 | 605 | } else { |
| 606 | 606 | return self::COMPLETE; |
@@ -649,7 +649,7 @@ discard block |
||
| 649 | 649 | private function searchResultToCacheEntries(Statement $result) { |
| 650 | 650 | $files = $result->fetchAll(); |
| 651 | 651 | |
| 652 | - return array_map(function (array $data) { |
|
| 652 | + return array_map(function(array $data) { |
|
| 653 | 653 | return self::cacheEntryFromData($data, $this->mimetypeLoader); |
| 654 | 654 | }, $files); |
| 655 | 655 | } |
@@ -668,7 +668,7 @@ discard block |
||
| 668 | 668 | $where = '`mimepart` = ?'; |
| 669 | 669 | } |
| 670 | 670 | $sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `storage_mtime`, `mtime`, `encrypted`, `etag`, `permissions`, `checksum` |
| 671 | - FROM `*PREFIX*filecache` WHERE ' . $where . ' AND `storage` = ?'; |
|
| 671 | + FROM `*PREFIX*filecache` WHERE ' . $where.' AND `storage` = ?'; |
|
| 672 | 672 | $mimetype = $this->mimetypeLoader->getId($mimetype); |
| 673 | 673 | $result = $this->connection->executeQuery($sql, array($mimetype, $this->getNumericStorageId())); |
| 674 | 674 | |
@@ -719,20 +719,20 @@ discard block |
||
| 719 | 719 | * @return ICacheEntry[] file data |
| 720 | 720 | */ |
| 721 | 721 | public function searchByTag($tag, $userId) { |
| 722 | - $sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, ' . |
|
| 723 | - '`mimetype`, `mimepart`, `size`, `mtime`, `storage_mtime`, ' . |
|
| 724 | - '`encrypted`, `etag`, `permissions`, `checksum` ' . |
|
| 725 | - 'FROM `*PREFIX*filecache` `file`, ' . |
|
| 726 | - '`*PREFIX*vcategory_to_object` `tagmap`, ' . |
|
| 727 | - '`*PREFIX*vcategory` `tag` ' . |
|
| 722 | + $sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, '. |
|
| 723 | + '`mimetype`, `mimepart`, `size`, `mtime`, `storage_mtime`, '. |
|
| 724 | + '`encrypted`, `etag`, `permissions`, `checksum` '. |
|
| 725 | + 'FROM `*PREFIX*filecache` `file`, '. |
|
| 726 | + '`*PREFIX*vcategory_to_object` `tagmap`, '. |
|
| 727 | + '`*PREFIX*vcategory` `tag` '. |
|
| 728 | 728 | // JOIN filecache to vcategory_to_object |
| 729 | - 'WHERE `file`.`fileid` = `tagmap`.`objid` ' . |
|
| 729 | + 'WHERE `file`.`fileid` = `tagmap`.`objid` '. |
|
| 730 | 730 | // JOIN vcategory_to_object to vcategory |
| 731 | - 'AND `tagmap`.`type` = `tag`.`type` ' . |
|
| 732 | - 'AND `tagmap`.`categoryid` = `tag`.`id` ' . |
|
| 731 | + 'AND `tagmap`.`type` = `tag`.`type` '. |
|
| 732 | + 'AND `tagmap`.`categoryid` = `tag`.`id` '. |
|
| 733 | 733 | // conditions |
| 734 | - 'AND `file`.`storage` = ? ' . |
|
| 735 | - 'AND `tag`.`type` = \'files\' ' . |
|
| 734 | + 'AND `file`.`storage` = ? '. |
|
| 735 | + 'AND `tag`.`type` = \'files\' '. |
|
| 736 | 736 | 'AND `tag`.`uid` = ? '; |
| 737 | 737 | if (is_int($tag)) { |
| 738 | 738 | $sql .= 'AND `tag`.`id` = ? '; |
@@ -750,7 +750,7 @@ discard block |
||
| 750 | 750 | |
| 751 | 751 | $files = $result->fetchAll(); |
| 752 | 752 | |
| 753 | - return array_map(function (array $data) { |
|
| 753 | + return array_map(function(array $data) { |
|
| 754 | 754 | return self::cacheEntryFromData($data, $this->mimetypeLoader); |
| 755 | 755 | }, $files); |
| 756 | 756 | } |
@@ -786,8 +786,8 @@ discard block |
||
| 786 | 786 | } |
| 787 | 787 | if (isset($entry['mimetype']) && $entry['mimetype'] === 'httpd/unix-directory') { |
| 788 | 788 | $id = $entry['fileid']; |
| 789 | - $sql = 'SELECT SUM(`size`) AS f1, MIN(`size`) AS f2 ' . |
|
| 790 | - 'FROM `*PREFIX*filecache` ' . |
|
| 789 | + $sql = 'SELECT SUM(`size`) AS f1, MIN(`size`) AS f2 '. |
|
| 790 | + 'FROM `*PREFIX*filecache` '. |
|
| 791 | 791 | 'WHERE `parent` = ? AND `storage` = ?'; |
| 792 | 792 | $result = $this->connection->executeQuery($sql, array($id, $this->getNumericStorageId())); |
| 793 | 793 | if ($row = $result->fetch()) { |