@@ -153,18 +153,18 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public static function cacheEntryFromData($data, IMimeTypeLoader $mimetypeLoader) { |
155 | 155 | //fix types |
156 | - $data['name'] = (string)$data['name']; |
|
157 | - $data['path'] = (string)$data['path']; |
|
158 | - $data['fileid'] = (int)$data['fileid']; |
|
159 | - $data['parent'] = (int)$data['parent']; |
|
156 | + $data['name'] = (string) $data['name']; |
|
157 | + $data['path'] = (string) $data['path']; |
|
158 | + $data['fileid'] = (int) $data['fileid']; |
|
159 | + $data['parent'] = (int) $data['parent']; |
|
160 | 160 | $data['size'] = Util::numericToNumber($data['size']); |
161 | 161 | $data['unencrypted_size'] = Util::numericToNumber($data['unencrypted_size'] ?? 0); |
162 | - $data['mtime'] = (int)$data['mtime']; |
|
163 | - $data['storage_mtime'] = (int)$data['storage_mtime']; |
|
164 | - $data['encryptedVersion'] = (int)$data['encrypted']; |
|
165 | - $data['encrypted'] = (bool)$data['encrypted']; |
|
162 | + $data['mtime'] = (int) $data['mtime']; |
|
163 | + $data['storage_mtime'] = (int) $data['storage_mtime']; |
|
164 | + $data['encryptedVersion'] = (int) $data['encrypted']; |
|
165 | + $data['encrypted'] = (bool) $data['encrypted']; |
|
166 | 166 | $data['storage_id'] = $data['storage']; |
167 | - $data['storage'] = (int)$data['storage']; |
|
167 | + $data['storage'] = (int) $data['storage']; |
|
168 | 168 | $data['mimetype'] = $mimetypeLoader->getMimetypeById($data['mimetype']); |
169 | 169 | $data['mimepart'] = $mimetypeLoader->getMimetypeById($data['mimepart']); |
170 | 170 | if ($data['storage_mtime'] == 0) { |
@@ -173,12 +173,12 @@ discard block |
||
173 | 173 | if (isset($data['f_permissions'])) { |
174 | 174 | $data['scan_permissions'] = $data['f_permissions']; |
175 | 175 | } |
176 | - $data['permissions'] = (int)$data['permissions']; |
|
176 | + $data['permissions'] = (int) $data['permissions']; |
|
177 | 177 | if (isset($data['creation_time'])) { |
178 | - $data['creation_time'] = (int)$data['creation_time']; |
|
178 | + $data['creation_time'] = (int) $data['creation_time']; |
|
179 | 179 | } |
180 | 180 | if (isset($data['upload_time'])) { |
181 | - $data['upload_time'] = (int)$data['upload_time']; |
|
181 | + $data['upload_time'] = (int) $data['upload_time']; |
|
182 | 182 | } |
183 | 183 | return new CacheEntry($data); |
184 | 184 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | $files = $result->fetchAll(); |
215 | 215 | $result->closeCursor(); |
216 | 216 | |
217 | - return array_map(function (array $data) use ($metadataQuery) { |
|
217 | + return array_map(function(array $data) use ($metadataQuery) { |
|
218 | 218 | $data['metadata'] = $metadataQuery->extractMetadata($data)->asArray(); |
219 | 219 | return self::cacheEntryFromData($data, $this->mimetypeLoader); |
220 | 220 | }, $files); |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | $data['parent'] = $this->getParentId($file); |
272 | 272 | } |
273 | 273 | if ($data['parent'] === -1 && $file !== '') { |
274 | - throw new \Exception('Parent folder not in filecache for ' . $file); |
|
274 | + throw new \Exception('Parent folder not in filecache for '.$file); |
|
275 | 275 | } |
276 | 276 | $data['name'] = basename($file); |
277 | 277 | |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | $query->update('filecache') |
350 | 350 | ->whereFileId($id) |
351 | 351 | ->whereStorageId($this->getNumericStorageId()) |
352 | - ->andWhere($query->expr()->orX(...array_map(function ($key, $value) use ($query) { |
|
352 | + ->andWhere($query->expr()->orX(...array_map(function($key, $value) use ($query) { |
|
353 | 353 | return $query->expr()->orX( |
354 | 354 | $query->expr()->neq($key, $query->createNamedParameter($value)), |
355 | 355 | $query->expr()->isNull($key) |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | $query->update('filecache_extended') |
381 | 381 | ->whereFileId($id) |
382 | 382 | ->hintShardKey('storage', $this->getNumericStorageId()) |
383 | - ->andWhere($query->expr()->orX(...array_map(function ($key, $value) use ($query) { |
|
383 | + ->andWhere($query->expr()->orX(...array_map(function($key, $value) use ($query) { |
|
384 | 384 | return $query->expr()->orX( |
385 | 385 | $query->expr()->neq($key, $query->createNamedParameter($value)), |
386 | 386 | $query->expr()->isNull($key) |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | $id = $result->fetchOne(); |
478 | 478 | $result->closeCursor(); |
479 | 479 | |
480 | - return $id === false ? -1 : (int)$id; |
|
480 | + return $id === false ? -1 : (int) $id; |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | /** |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | return -1; |
492 | 492 | } else { |
493 | 493 | $parent = $this->getParentPath($file); |
494 | - return (int)$this->getId($parent); |
|
494 | + return (int) $this->getId($parent); |
|
495 | 495 | } |
496 | 496 | } |
497 | 497 | |
@@ -560,10 +560,10 @@ discard block |
||
560 | 560 | // and collecting all folder ids to later use to delete the filecache entries |
561 | 561 | while ($entryId = array_pop($queue)) { |
562 | 562 | $children = $this->getFolderContentsById($entryId); |
563 | - $childIds = array_map(function (ICacheEntry $cacheEntry) { |
|
563 | + $childIds = array_map(function(ICacheEntry $cacheEntry) { |
|
564 | 564 | return $cacheEntry->getId(); |
565 | 565 | }, $children); |
566 | - $childPaths = array_map(function (ICacheEntry $cacheEntry) { |
|
566 | + $childPaths = array_map(function(ICacheEntry $cacheEntry) { |
|
567 | 567 | return $cacheEntry->getPath(); |
568 | 568 | }, $children); |
569 | 569 | |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | |
664 | 664 | $sourceData = $sourceCache->get($sourcePath); |
665 | 665 | if (!$sourceData) { |
666 | - throw new \Exception('Source path not found in cache: ' . $sourcePath); |
|
666 | + throw new \Exception('Source path not found in cache: '.$sourcePath); |
|
667 | 667 | } |
668 | 668 | |
669 | 669 | $shardDefinition = $this->connection->getShardDefinition('filecache'); |
@@ -682,10 +682,10 @@ discard block |
||
682 | 682 | [$targetStorageId, $targetPath] = $this->getMoveInfo($targetPath); |
683 | 683 | |
684 | 684 | if (is_null($sourceStorageId) || $sourceStorageId === false) { |
685 | - throw new \Exception('Invalid source storage id: ' . $sourceStorageId); |
|
685 | + throw new \Exception('Invalid source storage id: '.$sourceStorageId); |
|
686 | 686 | } |
687 | 687 | if (is_null($targetStorageId) || $targetStorageId === false) { |
688 | - throw new \Exception('Invalid target storage id: ' . $targetStorageId); |
|
688 | + throw new \Exception('Invalid target storage id: '.$targetStorageId); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | if ($sourceData['mimetype'] === 'httpd/unix-directory') { |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | $query->select('fileid') |
795 | 795 | ->from('filecache') |
796 | 796 | ->where($query->expr()->eq('storage', $query->createNamedParameter($storageId, IQueryBuilder::PARAM_INT))) |
797 | - ->andWhere($query->expr()->like('path', $query->createNamedParameter($this->connection->escapeLikeParameter($path) . '/%'))); |
|
797 | + ->andWhere($query->expr()->like('path', $query->createNamedParameter($this->connection->escapeLikeParameter($path).'/%'))); |
|
798 | 798 | return $query->executeQuery()->fetchAll(\PDO::FETCH_COLUMN); |
799 | 799 | } |
800 | 800 | |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | $result->closeCursor(); |
841 | 841 | |
842 | 842 | if ($size !== false) { |
843 | - if ((int)$size === -1) { |
|
843 | + if ((int) $size === -1) { |
|
844 | 844 | return self::SHALLOW; |
845 | 845 | } else { |
846 | 846 | return self::COMPLETE; |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | */ |
875 | 875 | public function searchByMime($mimetype) { |
876 | 876 | if (!str_contains($mimetype, '/')) { |
877 | - $operator = new SearchComparison(ISearchComparison::COMPARE_LIKE, 'mimetype', $mimetype . '/%'); |
|
877 | + $operator = new SearchComparison(ISearchComparison::COMPARE_LIKE, 'mimetype', $mimetype.'/%'); |
|
878 | 878 | } else { |
879 | 879 | $operator = new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', $mimetype); |
880 | 880 | } |
@@ -929,7 +929,7 @@ discard block |
||
929 | 929 | ->andWhere($query->expr()->eq('size', $query->createNamedParameter(-1, IQueryBuilder::PARAM_INT))); |
930 | 930 | |
931 | 931 | $result = $query->executeQuery(); |
932 | - $size = (int)$result->fetchOne(); |
|
932 | + $size = (int) $result->fetchOne(); |
|
933 | 933 | $result->closeCursor(); |
934 | 934 | |
935 | 935 | return $size; |
@@ -979,13 +979,13 @@ discard block |
||
979 | 979 | $result->closeCursor(); |
980 | 980 | |
981 | 981 | if ($rows) { |
982 | - $sizes = array_map(function (array $row) { |
|
982 | + $sizes = array_map(function(array $row) { |
|
983 | 983 | return Util::numericToNumber($row['size']); |
984 | 984 | }, $rows); |
985 | - $unencryptedOnlySizes = array_map(function (array $row) { |
|
985 | + $unencryptedOnlySizes = array_map(function(array $row) { |
|
986 | 986 | return Util::numericToNumber($row['unencrypted_size']); |
987 | 987 | }, $rows); |
988 | - $unencryptedSizes = array_map(function (array $row) { |
|
988 | + $unencryptedSizes = array_map(function(array $row) { |
|
989 | 989 | return Util::numericToNumber(($row['unencrypted_size'] > 0) ? $row['unencrypted_size'] : $row['size']); |
990 | 990 | }, $rows); |
991 | 991 | |
@@ -1052,8 +1052,8 @@ discard block |
||
1052 | 1052 | $files = $result->fetchAll(\PDO::FETCH_COLUMN); |
1053 | 1053 | $result->closeCursor(); |
1054 | 1054 | |
1055 | - return array_map(function ($id) { |
|
1056 | - return (int)$id; |
|
1055 | + return array_map(function($id) { |
|
1056 | + return (int) $id; |
|
1057 | 1057 | }, $files); |
1058 | 1058 | } |
1059 | 1059 | |
@@ -1079,7 +1079,7 @@ discard block |
||
1079 | 1079 | $path = $result->fetchOne(); |
1080 | 1080 | $result->closeCursor(); |
1081 | 1081 | |
1082 | - return $path === false ? false : (string)$path; |
|
1082 | + return $path === false ? false : (string) $path; |
|
1083 | 1083 | } |
1084 | 1084 | |
1085 | 1085 | /** |
@@ -1103,7 +1103,7 @@ discard block |
||
1103 | 1103 | return null; |
1104 | 1104 | } |
1105 | 1105 | |
1106 | - return (string)$path; |
|
1106 | + return (string) $path; |
|
1107 | 1107 | } |
1108 | 1108 | |
1109 | 1109 | /** |
@@ -1170,12 +1170,12 @@ discard block |
||
1170 | 1170 | |
1171 | 1171 | $fileId = $this->put($targetPath, $data); |
1172 | 1172 | if ($fileId <= 0) { |
1173 | - throw new \RuntimeException('Failed to copy to ' . $targetPath . ' from cache with source data ' . json_encode($data) . ' '); |
|
1173 | + throw new \RuntimeException('Failed to copy to '.$targetPath.' from cache with source data '.json_encode($data).' '); |
|
1174 | 1174 | } |
1175 | 1175 | if ($sourceEntry->getMimeType() === ICacheEntry::DIRECTORY_MIMETYPE) { |
1176 | 1176 | $folderContent = $sourceCache->getFolderContentsById($sourceEntry->getId()); |
1177 | 1177 | foreach ($folderContent as $subEntry) { |
1178 | - $subTargetPath = $targetPath . '/' . $subEntry->getName(); |
|
1178 | + $subTargetPath = $targetPath.'/'.$subEntry->getName(); |
|
1179 | 1179 | $this->copyFromCache($sourceCache, $subEntry, $subTargetPath); |
1180 | 1180 | } |
1181 | 1181 | } |
@@ -1241,7 +1241,7 @@ discard block |
||
1241 | 1241 | $cacheItem['parent'] = $this->getParentId($targetPath); |
1242 | 1242 | $cacheItem['name'] = basename($cacheItem['path']); |
1243 | 1243 | } else { |
1244 | - $cacheItem['path'] = $targetPath . '/' . substr($cacheItem['path'], $sourcePathLength + 1); // +1 for the leading slash |
|
1244 | + $cacheItem['path'] = $targetPath.'/'.substr($cacheItem['path'], $sourcePathLength + 1); // +1 for the leading slash |
|
1245 | 1245 | } |
1246 | 1246 | $cacheItem['path_hash'] = md5($cacheItem['path']); |
1247 | 1247 | $cacheItem['storage'] = $this->getNumericStorageId(); |