diff options
Diffstat (limited to 'lib/private/Files/Cache')
-rw-r--r-- | lib/private/Files/Cache/Cache.php | 68 | ||||
-rw-r--r-- | lib/private/Files/Cache/HomeCache.php | 1 | ||||
-rw-r--r-- | lib/private/Files/Cache/StorageGlobal.php | 6 |
3 files changed, 62 insertions, 13 deletions
diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index 8a173f35197..e74cc86d9c9 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -151,7 +151,9 @@ class Cache implements ICache { $query->whereFileId($file); } - $data = $query->execute()->fetch(); + $result = $query->execute(); + $data = $result->fetch(); + $result->closeCursor(); //merge partial data if (!$data and is_string($file) and isset($this->partial[$file])) { @@ -220,7 +222,10 @@ class Cache implements ICache { ->whereParent($fileId) ->orderBy('name', 'ASC'); - $files = $query->execute()->fetchAll(); + $result = $query->execute(); + $files = $result->fetchAll(); + $result->closeCursor(); + return array_map(function (array $data) { return self::cacheEntryFromData($data, $this->mimetypeLoader); }, $files); @@ -467,7 +472,10 @@ class Cache implements ICache { ->whereStorageId() ->wherePath($file); - $id = $query->execute()->fetchColumn(); + $result = $query->execute(); + $id = $result->fetchColumn(); + $result->closeCursor(); + return $id === false ? -1 : (int)$id; } @@ -710,7 +718,11 @@ class Cache implements ICache { ->from('filecache') ->whereStorageId() ->wherePath($file); - $size = $query->execute()->fetchColumn(); + + $result = $query->execute(); + $size = $result->fetchColumn(); + $result->closeCursor(); + if ($size !== false) { if ((int)$size === -1) { return self::SHALLOW; @@ -745,9 +757,13 @@ class Cache implements ICache { ->whereStorageId() ->andWhere($query->expr()->iLike('name', $query->createNamedParameter($pattern))); + $result = $query->execute(); + $files = $result->fetchAll(); + $result->closeCursor(); + return array_map(function (array $data) { return self::cacheEntryFromData($data, $this->mimetypeLoader); - }, $query->execute()->fetchAll()); + }, $files); } /** @@ -782,9 +798,13 @@ class Cache implements ICache { $query->andWhere($query->expr()->eq('mimepart', $query->createNamedParameter($mimeId, IQueryBuilder::PARAM_INT))); } + $result = $query->execute(); + $files = $result->fetchAll(); + $result->closeCursor(); + return array_map(function (array $data) { return self::cacheEntryFromData($data, $this->mimetypeLoader); - }, $query->execute()->fetchAll()); + }, $files); } public function searchQuery(ISearchQuery $searchQuery) { @@ -865,7 +885,11 @@ class Cache implements ICache { ->whereParent($fileId) ->andWhere($query->expr()->lt('size', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT))); - return (int)$query->execute()->fetchColumn(); + $result = $query->execute(); + $size = (int)$result->fetchColumn(); + $result->closeCursor(); + + return $size; } return -1; } @@ -892,7 +916,11 @@ class Cache implements ICache { ->whereStorageId() ->whereParent($id); - if ($row = $query->execute()->fetch()) { + $result = $query->execute(); + $row = $result->fetch(); + $result->closeCursor(); + + if ($row) { [$sum, $min] = array_values($row); $sum = 0 + $sum; $min = 0 + $min; @@ -920,9 +948,13 @@ class Cache implements ICache { ->from('filecache') ->whereStorageId(); + $result = $query->execute(); + $files = $result->fetchAll(\PDO::FETCH_COLUMN); + $result->closeCursor(); + return array_map(function ($id) { return (int)$id; - }, $query->execute()->fetchAll(\PDO::FETCH_COLUMN)); + }, $files); } /** @@ -942,7 +974,11 @@ class Cache implements ICache { ->andWhere($query->expr()->lt('size', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT))) ->orderBy('fileid', 'DESC'); - return $query->execute()->fetchColumn(); + $result = $query->execute(); + $path = $result->fetchColumn(); + $result->closeCursor(); + + return $path; } /** @@ -958,7 +994,10 @@ class Cache implements ICache { ->whereStorageId() ->whereFileId($id); - $path = $query->execute()->fetchColumn(); + $result = $query->execute(); + $path = $result->fetchColumn(); + $result->closeCursor(); + return $path === false ? null : $path; } @@ -976,7 +1015,12 @@ class Cache implements ICache { $query->select('path', 'storage') ->from('filecache') ->where($query->expr()->eq('fileid', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT))); - if ($row = $query->execute()->fetch()) { + + $result = $query->execute(); + $row = $result->fetch(); + $result->closeCursor(); + + if ($row) { $numericId = $row['storage']; $path = $row['path']; } else { diff --git a/lib/private/Files/Cache/HomeCache.php b/lib/private/Files/Cache/HomeCache.php index e66ed7d9722..f7fc806456d 100644 --- a/lib/private/Files/Cache/HomeCache.php +++ b/lib/private/Files/Cache/HomeCache.php @@ -72,6 +72,7 @@ class HomeCache extends Cache { $this->update($id, ['size' => $totalSize]); } } + $result->closeCursor(); } return $totalSize; } diff --git a/lib/private/Files/Cache/StorageGlobal.php b/lib/private/Files/Cache/StorageGlobal.php index 26a7be24634..8bf37514b8b 100644 --- a/lib/private/Files/Cache/StorageGlobal.php +++ b/lib/private/Files/Cache/StorageGlobal.php @@ -61,6 +61,7 @@ class StorageGlobal { while ($row = $result->fetch()) { $this->cache[$row['id']] = $row; } + $result->closeCursor(); } /** @@ -74,7 +75,10 @@ class StorageGlobal { ->from('storages') ->where($builder->expr()->eq('id', $builder->createNamedParameter($storageId))); - $row = $query->execute()->fetch(); + $result = $query->execute(); + $row = $result->fetch(); + $result->closeCursor(); + if ($row) { $this->cache[$storageId] = $row; } |