diff --git a/lib/private/Preview/Storage/LocalPreviewStorage.php b/lib/private/Preview/Storage/LocalPreviewStorage.php index a64fdfe295f..13e6a714516 100644 --- a/lib/private/Preview/Storage/LocalPreviewStorage.php +++ b/lib/private/Preview/Storage/LocalPreviewStorage.php @@ -310,13 +310,14 @@ class LocalPreviewStorage implements IPreviewStorage { } $result = []; + $qb = $this->connection->getTypedQueryBuilder(); + $qb->selectColumns('fileid', 'storage', 'etag', 'mimetype') + ->from('filecache') + ->where($qb->expr()->in('fileid', $qb->createParameter('fileIds'))) + ->runAcrossAllShards(); foreach (array_chunk($fileIds, 1000) as $chunk) { - $qb = $this->connection->getTypedQueryBuilder(); - $qb->selectColumns('fileid', 'storage', 'etag', 'mimetype') - ->from('filecache') - ->where($qb->expr()->in('fileid', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_INT_ARRAY))); - $rows = $qb->runAcrossAllShards() - ->executeQuery(); + $qb->setParameter('fileIds', $chunk, IQueryBuilder::PARAM_INT_ARRAY); + $rows = $qb->executeQuery(); while ($row = $rows->fetchAssociative()) { $result[(int)$row['fileid']] = $row; } @@ -336,13 +337,14 @@ class LocalPreviewStorage implements IPreviewStorage { } $result = []; + $qb = $this->connection->getTypedQueryBuilder(); + $qb->selectColumns('fileid', 'storage', 'etag', 'mimetype', 'parent', 'path_hash') + ->from('filecache') + ->where($qb->expr()->in('path_hash', $qb->createParameter('pathHashes'))) + ->runAcrossAllShards(); foreach (array_chunk($pathHashes, 1000) as $chunk) { - $qb = $this->connection->getTypedQueryBuilder(); - $qb->selectColumns('fileid', 'storage', 'etag', 'mimetype', 'parent', 'path_hash') - ->from('filecache') - ->where($qb->expr()->in('path_hash', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_STR_ARRAY))); - $rows = $qb->runAcrossAllShards() - ->executeQuery(); + $qb->setParameter('pathHashes', $chunk, IQueryBuilder::PARAM_STR_ARRAY); + $rows = $qb->executeQuery(); while ($row = $rows->fetchAssociative()) { $result[$row['path_hash']] = $row; } diff --git a/tests/lib/Preview/Storage/LocalPreviewStorageTest.php b/tests/lib/Preview/Storage/LocalPreviewStorageTest.php index dbc3cea5342..14e6419a9d5 100644 --- a/tests/lib/Preview/Storage/LocalPreviewStorageTest.php +++ b/tests/lib/Preview/Storage/LocalPreviewStorageTest.php @@ -129,6 +129,7 @@ class LocalPreviewStorageTest extends TestCase { $qbMock = $this->createMock(ITypedQueryBuilder::class); $qbMock->method('selectColumns')->willReturnSelf(); $qbMock->method('from')->willReturnSelf(); + $qbMock->method('where')->willReturnSelf(); $qbMock->method('andWhere')->willReturnSelf(); $qbMock->method('runAcrossAllShards')->willReturnSelf(); $qbMock->method('executeQuery')->willReturn($resultMock);