@@ -155,18 +155,18 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | public static function cacheEntryFromData($data, IMimeTypeLoader $mimetypeLoader) { |
| 157 | 157 | //fix types |
| 158 | - $data['name'] = (string)$data['name']; |
|
| 159 | - $data['path'] = (string)$data['path']; |
|
| 160 | - $data['fileid'] = (int)$data['fileid']; |
|
| 161 | - $data['parent'] = (int)$data['parent']; |
|
| 158 | + $data['name'] = (string) $data['name']; |
|
| 159 | + $data['path'] = (string) $data['path']; |
|
| 160 | + $data['fileid'] = (int) $data['fileid']; |
|
| 161 | + $data['parent'] = (int) $data['parent']; |
|
| 162 | 162 | $data['size'] = Util::numericToNumber($data['size']); |
| 163 | 163 | $data['unencrypted_size'] = Util::numericToNumber($data['unencrypted_size'] ?? 0); |
| 164 | - $data['mtime'] = (int)$data['mtime']; |
|
| 165 | - $data['storage_mtime'] = (int)$data['storage_mtime']; |
|
| 166 | - $data['encryptedVersion'] = (int)$data['encrypted']; |
|
| 167 | - $data['encrypted'] = (bool)$data['encrypted']; |
|
| 164 | + $data['mtime'] = (int) $data['mtime']; |
|
| 165 | + $data['storage_mtime'] = (int) $data['storage_mtime']; |
|
| 166 | + $data['encryptedVersion'] = (int) $data['encrypted']; |
|
| 167 | + $data['encrypted'] = (bool) $data['encrypted']; |
|
| 168 | 168 | $data['storage_id'] = $data['storage']; |
| 169 | - $data['storage'] = (int)$data['storage']; |
|
| 169 | + $data['storage'] = (int) $data['storage']; |
|
| 170 | 170 | $data['mimetype'] = $mimetypeLoader->getMimetypeById($data['mimetype']); |
| 171 | 171 | $data['mimepart'] = $mimetypeLoader->getMimetypeById($data['mimepart']); |
| 172 | 172 | if ($data['storage_mtime'] == 0) { |
@@ -175,12 +175,12 @@ discard block |
||
| 175 | 175 | if (isset($data['f_permissions'])) { |
| 176 | 176 | $data['scan_permissions'] ??= $data['f_permissions']; |
| 177 | 177 | } |
| 178 | - $data['permissions'] = (int)$data['permissions']; |
|
| 178 | + $data['permissions'] = (int) $data['permissions']; |
|
| 179 | 179 | if (isset($data['creation_time'])) { |
| 180 | - $data['creation_time'] = (int)$data['creation_time']; |
|
| 180 | + $data['creation_time'] = (int) $data['creation_time']; |
|
| 181 | 181 | } |
| 182 | 182 | if (isset($data['upload_time'])) { |
| 183 | - $data['upload_time'] = (int)$data['upload_time']; |
|
| 183 | + $data['upload_time'] = (int) $data['upload_time']; |
|
| 184 | 184 | } |
| 185 | 185 | return new CacheEntry($data); |
| 186 | 186 | } |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | $files = $result->fetchAll(); |
| 217 | 217 | $result->closeCursor(); |
| 218 | 218 | |
| 219 | - return array_map(function (array $data) use ($metadataQuery) { |
|
| 219 | + return array_map(function(array $data) use ($metadataQuery) { |
|
| 220 | 220 | $data['metadata'] = $metadataQuery->extractMetadata($data)->asArray(); |
| 221 | 221 | return self::cacheEntryFromData($data, $this->mimetypeLoader); |
| 222 | 222 | }, $files); |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | $data['parent'] = $this->getParentId($file); |
| 274 | 274 | } |
| 275 | 275 | if ($data['parent'] === -1 && $file !== '') { |
| 276 | - throw new \Exception('Parent folder not in filecache for ' . $file); |
|
| 276 | + throw new \Exception('Parent folder not in filecache for '.$file); |
|
| 277 | 277 | } |
| 278 | 278 | $data['name'] = basename($file); |
| 279 | 279 | |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | $query->update('filecache') |
| 356 | 356 | ->whereFileId($id) |
| 357 | 357 | ->whereStorageId($this->getNumericStorageId()) |
| 358 | - ->andWhere($query->expr()->orX(...array_map(function ($key, $value) use ($query) { |
|
| 358 | + ->andWhere($query->expr()->orX(...array_map(function($key, $value) use ($query) { |
|
| 359 | 359 | return $query->expr()->orX( |
| 360 | 360 | $query->expr()->neq($key, $query->createNamedParameter($value)), |
| 361 | 361 | $query->expr()->isNull($key) |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | $query->update('filecache_extended') |
| 390 | 390 | ->whereFileId($id) |
| 391 | 391 | ->hintShardKey('storage', $this->getNumericStorageId()) |
| 392 | - ->andWhere($query->expr()->orX(...array_map(function ($key, $value) use ($query) { |
|
| 392 | + ->andWhere($query->expr()->orX(...array_map(function($key, $value) use ($query) { |
|
| 393 | 393 | return $query->expr()->orX( |
| 394 | 394 | $query->expr()->neq($key, $query->createNamedParameter($value)), |
| 395 | 395 | $query->expr()->isNull($key) |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | $id = $result->fetchOne(); |
| 487 | 487 | $result->closeCursor(); |
| 488 | 488 | |
| 489 | - return $id === false ? -1 : (int)$id; |
|
| 489 | + return $id === false ? -1 : (int) $id; |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | /** |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | return -1; |
| 501 | 501 | } else { |
| 502 | 502 | $parent = $this->getParentPath($file); |
| 503 | - return (int)$this->getId($parent); |
|
| 503 | + return (int) $this->getId($parent); |
|
| 504 | 504 | } |
| 505 | 505 | } |
| 506 | 506 | |
@@ -569,10 +569,10 @@ discard block |
||
| 569 | 569 | // and collecting all folder ids to later use to delete the filecache entries |
| 570 | 570 | while ($entryId = array_pop($queue)) { |
| 571 | 571 | $children = $this->getFolderContentsById($entryId); |
| 572 | - $childIds = array_map(function (ICacheEntry $cacheEntry) { |
|
| 572 | + $childIds = array_map(function(ICacheEntry $cacheEntry) { |
|
| 573 | 573 | return $cacheEntry->getId(); |
| 574 | 574 | }, $children); |
| 575 | - $childPaths = array_map(function (ICacheEntry $cacheEntry) { |
|
| 575 | + $childPaths = array_map(function(ICacheEntry $cacheEntry) { |
|
| 576 | 576 | return $cacheEntry->getPath(); |
| 577 | 577 | }, $children); |
| 578 | 578 | |
@@ -679,7 +679,7 @@ discard block |
||
| 679 | 679 | |
| 680 | 680 | $sourceData = $sourceCache->get($sourcePath); |
| 681 | 681 | if (!$sourceData) { |
| 682 | - throw new \Exception('Source path not found in cache: ' . $sourcePath); |
|
| 682 | + throw new \Exception('Source path not found in cache: '.$sourcePath); |
|
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | $shardDefinition = $this->connection->getShardDefinition('filecache'); |
@@ -698,10 +698,10 @@ discard block |
||
| 698 | 698 | [$targetStorageId, $targetPath] = $this->getMoveInfo($targetPath); |
| 699 | 699 | |
| 700 | 700 | if (is_null($sourceStorageId) || $sourceStorageId === false) { |
| 701 | - throw new \Exception('Invalid source storage id: ' . $sourceStorageId); |
|
| 701 | + throw new \Exception('Invalid source storage id: '.$sourceStorageId); |
|
| 702 | 702 | } |
| 703 | 703 | if (is_null($targetStorageId) || $targetStorageId === false) { |
| 704 | - throw new \Exception('Invalid target storage id: ' . $targetStorageId); |
|
| 704 | + throw new \Exception('Invalid target storage id: '.$targetStorageId); |
|
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | if ($sourceData['mimetype'] === 'httpd/unix-directory') { |
@@ -810,7 +810,7 @@ discard block |
||
| 810 | 810 | $query->select('fileid') |
| 811 | 811 | ->from('filecache') |
| 812 | 812 | ->where($query->expr()->eq('storage', $query->createNamedParameter($storageId, IQueryBuilder::PARAM_INT))) |
| 813 | - ->andWhere($query->expr()->like('path', $query->createNamedParameter($this->connection->escapeLikeParameter($path) . '/%'))); |
|
| 813 | + ->andWhere($query->expr()->like('path', $query->createNamedParameter($this->connection->escapeLikeParameter($path).'/%'))); |
|
| 814 | 814 | return $query->executeQuery()->fetchAll(\PDO::FETCH_COLUMN); |
| 815 | 815 | } |
| 816 | 816 | |
@@ -856,7 +856,7 @@ discard block |
||
| 856 | 856 | $result->closeCursor(); |
| 857 | 857 | |
| 858 | 858 | if ($size !== false) { |
| 859 | - if ((int)$size === -1) { |
|
| 859 | + if ((int) $size === -1) { |
|
| 860 | 860 | return self::SHALLOW; |
| 861 | 861 | } else { |
| 862 | 862 | return self::COMPLETE; |
@@ -890,7 +890,7 @@ discard block |
||
| 890 | 890 | */ |
| 891 | 891 | public function searchByMime($mimetype) { |
| 892 | 892 | if (!str_contains($mimetype, '/')) { |
| 893 | - $operator = new SearchComparison(ISearchComparison::COMPARE_LIKE, 'mimetype', $mimetype . '/%'); |
|
| 893 | + $operator = new SearchComparison(ISearchComparison::COMPARE_LIKE, 'mimetype', $mimetype.'/%'); |
|
| 894 | 894 | } else { |
| 895 | 895 | $operator = new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', $mimetype); |
| 896 | 896 | } |
@@ -945,7 +945,7 @@ discard block |
||
| 945 | 945 | ->andWhere($query->expr()->eq('size', $query->createNamedParameter(-1, IQueryBuilder::PARAM_INT))); |
| 946 | 946 | |
| 947 | 947 | $result = $query->executeQuery(); |
| 948 | - $size = (int)$result->fetchOne(); |
|
| 948 | + $size = (int) $result->fetchOne(); |
|
| 949 | 949 | $result->closeCursor(); |
| 950 | 950 | |
| 951 | 951 | return $size; |
@@ -995,13 +995,13 @@ discard block |
||
| 995 | 995 | $result->closeCursor(); |
| 996 | 996 | |
| 997 | 997 | if ($rows) { |
| 998 | - $sizes = array_map(function (array $row) { |
|
| 998 | + $sizes = array_map(function(array $row) { |
|
| 999 | 999 | return Util::numericToNumber($row['size']); |
| 1000 | 1000 | }, $rows); |
| 1001 | - $unencryptedOnlySizes = array_map(function (array $row) { |
|
| 1001 | + $unencryptedOnlySizes = array_map(function(array $row) { |
|
| 1002 | 1002 | return Util::numericToNumber($row['unencrypted_size']); |
| 1003 | 1003 | }, $rows); |
| 1004 | - $unencryptedSizes = array_map(function (array $row) { |
|
| 1004 | + $unencryptedSizes = array_map(function(array $row) { |
|
| 1005 | 1005 | return Util::numericToNumber(($row['unencrypted_size'] > 0) ? $row['unencrypted_size'] : $row['size']); |
| 1006 | 1006 | }, $rows); |
| 1007 | 1007 | |
@@ -1068,8 +1068,8 @@ discard block |
||
| 1068 | 1068 | $files = $result->fetchAll(\PDO::FETCH_COLUMN); |
| 1069 | 1069 | $result->closeCursor(); |
| 1070 | 1070 | |
| 1071 | - return array_map(function ($id) { |
|
| 1072 | - return (int)$id; |
|
| 1071 | + return array_map(function($id) { |
|
| 1072 | + return (int) $id; |
|
| 1073 | 1073 | }, $files); |
| 1074 | 1074 | } |
| 1075 | 1075 | |
@@ -1095,7 +1095,7 @@ discard block |
||
| 1095 | 1095 | $path = $result->fetchOne(); |
| 1096 | 1096 | $result->closeCursor(); |
| 1097 | 1097 | |
| 1098 | - return $path === false ? false : (string)$path; |
|
| 1098 | + return $path === false ? false : (string) $path; |
|
| 1099 | 1099 | } |
| 1100 | 1100 | |
| 1101 | 1101 | /** |
@@ -1119,7 +1119,7 @@ discard block |
||
| 1119 | 1119 | return null; |
| 1120 | 1120 | } |
| 1121 | 1121 | |
| 1122 | - return (string)$path; |
|
| 1122 | + return (string) $path; |
|
| 1123 | 1123 | } |
| 1124 | 1124 | |
| 1125 | 1125 | /** |
@@ -1188,12 +1188,12 @@ discard block |
||
| 1188 | 1188 | |
| 1189 | 1189 | $fileId = $this->put($targetPath, $data); |
| 1190 | 1190 | if ($fileId <= 0) { |
| 1191 | - throw new \RuntimeException('Failed to copy to ' . $targetPath . ' from cache with source data ' . json_encode($data) . ' '); |
|
| 1191 | + throw new \RuntimeException('Failed to copy to '.$targetPath.' from cache with source data '.json_encode($data).' '); |
|
| 1192 | 1192 | } |
| 1193 | 1193 | if ($sourceEntry->getMimeType() === ICacheEntry::DIRECTORY_MIMETYPE) { |
| 1194 | 1194 | $folderContent = $sourceCache->getFolderContentsById($sourceEntry->getId()); |
| 1195 | 1195 | foreach ($folderContent as $subEntry) { |
| 1196 | - $subTargetPath = $targetPath . '/' . $subEntry->getName(); |
|
| 1196 | + $subTargetPath = $targetPath.'/'.$subEntry->getName(); |
|
| 1197 | 1197 | $this->copyFromCache($sourceCache, $subEntry, $subTargetPath); |
| 1198 | 1198 | } |
| 1199 | 1199 | } |
@@ -1267,7 +1267,7 @@ discard block |
||
| 1267 | 1267 | $cacheItem['parent'] = $this->getParentId($targetPath); |
| 1268 | 1268 | $cacheItem['name'] = basename($cacheItem['path']); |
| 1269 | 1269 | } else { |
| 1270 | - $cacheItem['path'] = $targetPath . '/' . substr($cacheItem['path'], $sourcePathLength + 1); // +1 for the leading slash |
|
| 1270 | + $cacheItem['path'] = $targetPath.'/'.substr($cacheItem['path'], $sourcePathLength + 1); // +1 for the leading slash |
|
| 1271 | 1271 | } |
| 1272 | 1272 | $cacheItem['path_hash'] = md5($cacheItem['path']); |
| 1273 | 1273 | $cacheItem['storage'] = $this->getNumericStorageId(); |