@@ -170,21 +170,21 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public static function cacheEntryFromData($data, IMimeTypeLoader $mimetypeLoader) { |
172 | 172 | //fix types |
173 | - $data['fileid'] = (int)$data['fileid']; |
|
174 | - $data['parent'] = (int)$data['parent']; |
|
173 | + $data['fileid'] = (int) $data['fileid']; |
|
174 | + $data['parent'] = (int) $data['parent']; |
|
175 | 175 | $data['size'] = 0 + $data['size']; |
176 | - $data['mtime'] = (int)$data['mtime']; |
|
177 | - $data['storage_mtime'] = (int)$data['storage_mtime']; |
|
178 | - $data['encryptedVersion'] = (int)$data['encrypted']; |
|
179 | - $data['encrypted'] = (bool)$data['encrypted']; |
|
176 | + $data['mtime'] = (int) $data['mtime']; |
|
177 | + $data['storage_mtime'] = (int) $data['storage_mtime']; |
|
178 | + $data['encryptedVersion'] = (int) $data['encrypted']; |
|
179 | + $data['encrypted'] = (bool) $data['encrypted']; |
|
180 | 180 | $data['storage_id'] = $data['storage']; |
181 | - $data['storage'] = (int)$data['storage']; |
|
181 | + $data['storage'] = (int) $data['storage']; |
|
182 | 182 | $data['mimetype'] = $mimetypeLoader->getMimetypeById($data['mimetype']); |
183 | 183 | $data['mimepart'] = $mimetypeLoader->getMimetypeById($data['mimepart']); |
184 | 184 | if ($data['storage_mtime'] == 0) { |
185 | 185 | $data['storage_mtime'] = $data['mtime']; |
186 | 186 | } |
187 | - $data['permissions'] = (int)$data['permissions']; |
|
187 | + $data['permissions'] = (int) $data['permissions']; |
|
188 | 188 | return new CacheEntry($data); |
189 | 189 | } |
190 | 190 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | FROM `*PREFIX*filecache` WHERE `parent` = ? ORDER BY `name` ASC'; |
213 | 213 | $result = $this->connection->executeQuery($sql, [$fileId]); |
214 | 214 | $files = $result->fetchAll(); |
215 | - return array_map(function (array $data) { |
|
215 | + return array_map(function(array $data) { |
|
216 | 216 | return self::cacheEntryFromData($data, $this->mimetypeLoader); |
217 | 217 | }, $files); |
218 | 218 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | $queryParts[] = '`storage`'; |
274 | 274 | $params[] = $this->getNumericStorageId(); |
275 | 275 | |
276 | - $queryParts = array_map(function ($item) { |
|
276 | + $queryParts = array_map(function($item) { |
|
277 | 277 | return trim($item, "`"); |
278 | 278 | }, $queryParts); |
279 | 279 | $values = array_combine($queryParts, $params); |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | } |
288 | 288 | |
289 | 289 | if ($builder->execute()) { |
290 | - $fileId = (int)$this->connection->lastInsertId('*PREFIX*filecache'); |
|
290 | + $fileId = (int) $this->connection->lastInsertId('*PREFIX*filecache'); |
|
291 | 291 | $this->eventDispatcher->dispatch(CacheInsertEvent::class, new CacheInsertEvent($this->storage, $file, $fileId)); |
292 | 292 | return $fileId; |
293 | 293 | } |
@@ -330,10 +330,10 @@ discard block |
||
330 | 330 | |
331 | 331 | // don't update if the data we try to set is the same as the one in the record |
332 | 332 | // some databases (Postgres) don't like superfluous updates |
333 | - $sql = 'UPDATE `*PREFIX*filecache` SET ' . implode(' = ?, ', $queryParts) . '=? ' . |
|
334 | - 'WHERE (' . |
|
335 | - implode(' <> ? OR ', $queryParts) . ' <> ? OR ' . |
|
336 | - implode(' IS NULL OR ', $queryParts) . ' IS NULL' . |
|
333 | + $sql = 'UPDATE `*PREFIX*filecache` SET '.implode(' = ?, ', $queryParts).'=? '. |
|
334 | + 'WHERE ('. |
|
335 | + implode(' <> ? OR ', $queryParts).' <> ? OR '. |
|
336 | + implode(' IS NULL OR ', $queryParts).' IS NULL'. |
|
337 | 337 | ') AND `fileid` = ? '; |
338 | 338 | $this->connection->executeQuery($sql, $params); |
339 | 339 | |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | } |
385 | 385 | } |
386 | 386 | $params[] = $value; |
387 | - $queryParts[] = '`' . $name . '`'; |
|
387 | + $queryParts[] = '`'.$name.'`'; |
|
388 | 388 | } |
389 | 389 | } |
390 | 390 | return array($queryParts, $params); |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | return -1; |
427 | 427 | } else { |
428 | 428 | $parent = $this->getParentPath($file); |
429 | - return (int)$this->getId($parent); |
|
429 | + return (int) $this->getId($parent); |
|
430 | 430 | } |
431 | 431 | } |
432 | 432 | |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | */ |
473 | 473 | private function getSubFolders($entry) { |
474 | 474 | $children = $this->getFolderContentsById($entry['fileid']); |
475 | - return array_filter($children, function ($child) { |
|
475 | + return array_filter($children, function($child) { |
|
476 | 476 | return $child['mimetype'] === 'httpd/unix-directory'; |
477 | 477 | }); |
478 | 478 | } |
@@ -536,10 +536,10 @@ discard block |
||
536 | 536 | list($targetStorageId, $targetPath) = $this->getMoveInfo($targetPath); |
537 | 537 | |
538 | 538 | if (is_null($sourceStorageId) || $sourceStorageId === false) { |
539 | - throw new \Exception('Invalid source storage id: ' . $sourceStorageId); |
|
539 | + throw new \Exception('Invalid source storage id: '.$sourceStorageId); |
|
540 | 540 | } |
541 | 541 | if (is_null($targetStorageId) || $targetStorageId === false) { |
542 | - throw new \Exception('Invalid target storage id: ' . $targetStorageId); |
|
542 | + throw new \Exception('Invalid target storage id: '.$targetStorageId); |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | $this->connection->beginTransaction(); |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | ->set('path_hash', $fun->md5($newPathFunction)) |
559 | 559 | ->set('path', $newPathFunction) |
560 | 560 | ->where($query->expr()->eq('storage', $query->createNamedParameter($sourceStorageId, IQueryBuilder::PARAM_INT))) |
561 | - ->andWhere($query->expr()->like('path', $query->createNamedParameter($this->connection->escapeLikeParameter($sourcePath) . '/%'))); |
|
561 | + ->andWhere($query->expr()->like('path', $query->createNamedParameter($this->connection->escapeLikeParameter($sourcePath).'/%'))); |
|
562 | 562 | |
563 | 563 | try { |
564 | 564 | $query->execute(); |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | $sql = 'SELECT `size` FROM `*PREFIX*filecache` WHERE `storage` = ? AND `path_hash` = ?'; |
608 | 608 | $result = $this->connection->executeQuery($sql, array($this->getNumericStorageId(), $pathHash)); |
609 | 609 | if ($row = $result->fetch()) { |
610 | - if ((int)$row['size'] === -1) { |
|
610 | + if ((int) $row['size'] === -1) { |
|
611 | 611 | return self::SHALLOW; |
612 | 612 | } else { |
613 | 613 | return self::COMPLETE; |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | private function searchResultToCacheEntries(Statement $result) { |
657 | 657 | $files = $result->fetchAll(); |
658 | 658 | |
659 | - return array_map(function (array $data) { |
|
659 | + return array_map(function(array $data) { |
|
660 | 660 | return self::cacheEntryFromData($data, $this->mimetypeLoader); |
661 | 661 | }, $files); |
662 | 662 | } |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | $where = '`mimepart` = ?'; |
676 | 676 | } |
677 | 677 | $sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `storage_mtime`, `mtime`, `encrypted`, `etag`, `permissions`, `checksum` |
678 | - FROM `*PREFIX*filecache` WHERE ' . $where . ' AND `storage` = ?'; |
|
678 | + FROM `*PREFIX*filecache` WHERE ' . $where.' AND `storage` = ?'; |
|
679 | 679 | $mimetype = $this->mimetypeLoader->getId($mimetype); |
680 | 680 | $result = $this->connection->executeQuery($sql, array($mimetype, $this->getNumericStorageId())); |
681 | 681 | |
@@ -726,20 +726,20 @@ discard block |
||
726 | 726 | * @return ICacheEntry[] file data |
727 | 727 | */ |
728 | 728 | public function searchByTag($tag, $userId) { |
729 | - $sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, ' . |
|
730 | - '`mimetype`, `mimepart`, `size`, `mtime`, `storage_mtime`, ' . |
|
731 | - '`encrypted`, `etag`, `permissions`, `checksum` ' . |
|
732 | - 'FROM `*PREFIX*filecache` `file`, ' . |
|
733 | - '`*PREFIX*vcategory_to_object` `tagmap`, ' . |
|
734 | - '`*PREFIX*vcategory` `tag` ' . |
|
729 | + $sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, '. |
|
730 | + '`mimetype`, `mimepart`, `size`, `mtime`, `storage_mtime`, '. |
|
731 | + '`encrypted`, `etag`, `permissions`, `checksum` '. |
|
732 | + 'FROM `*PREFIX*filecache` `file`, '. |
|
733 | + '`*PREFIX*vcategory_to_object` `tagmap`, '. |
|
734 | + '`*PREFIX*vcategory` `tag` '. |
|
735 | 735 | // JOIN filecache to vcategory_to_object |
736 | - 'WHERE `file`.`fileid` = `tagmap`.`objid` ' . |
|
736 | + 'WHERE `file`.`fileid` = `tagmap`.`objid` '. |
|
737 | 737 | // JOIN vcategory_to_object to vcategory |
738 | - 'AND `tagmap`.`type` = `tag`.`type` ' . |
|
739 | - 'AND `tagmap`.`categoryid` = `tag`.`id` ' . |
|
738 | + 'AND `tagmap`.`type` = `tag`.`type` '. |
|
739 | + 'AND `tagmap`.`categoryid` = `tag`.`id` '. |
|
740 | 740 | // conditions |
741 | - 'AND `file`.`storage` = ? ' . |
|
742 | - 'AND `tag`.`type` = \'files\' ' . |
|
741 | + 'AND `file`.`storage` = ? '. |
|
742 | + 'AND `tag`.`type` = \'files\' '. |
|
743 | 743 | 'AND `tag`.`uid` = ? '; |
744 | 744 | if (is_int($tag)) { |
745 | 745 | $sql .= 'AND `tag`.`id` = ? '; |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | |
758 | 758 | $files = $result->fetchAll(); |
759 | 759 | |
760 | - return array_map(function (array $data) { |
|
760 | + return array_map(function(array $data) { |
|
761 | 761 | return self::cacheEntryFromData($data, $this->mimetypeLoader); |
762 | 762 | }, $files); |
763 | 763 | } |
@@ -793,8 +793,8 @@ discard block |
||
793 | 793 | } |
794 | 794 | if (isset($entry['mimetype']) && $entry['mimetype'] === 'httpd/unix-directory') { |
795 | 795 | $id = $entry['fileid']; |
796 | - $sql = 'SELECT SUM(`size`) AS f1, MIN(`size`) AS f2 ' . |
|
797 | - 'FROM `*PREFIX*filecache` ' . |
|
796 | + $sql = 'SELECT SUM(`size`) AS f1, MIN(`size`) AS f2 '. |
|
797 | + 'FROM `*PREFIX*filecache` '. |
|
798 | 798 | 'WHERE `parent` = ? AND `storage` = ?'; |
799 | 799 | $result = $this->connection->executeQuery($sql, array($id, $this->getNumericStorageId())); |
800 | 800 | if ($row = $result->fetch()) { |