fix(previews): fix chunking for querybuilder

Signed-off-by: Anna Larch <anna@nextcloud.com>
This commit is contained in:
Anna Larch 2026-04-07 12:31:56 +02:00
parent d56ad83c1c
commit 59144ace90

View file

@ -310,20 +310,18 @@ class LocalPreviewStorage implements IPreviewStorage {
}
$result = [];
$qb = $this->connection->getTypedQueryBuilder();
$qb->selectColumns('fileid', 'storage', 'etag', 'mimetype')
->from('filecache');
foreach (array_chunk($fileIds, 1000) as $chunk) {
$qb->andWhere(
$qb->expr()->in('fileid', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_INT_ARRAY))
);
$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();
while ($row = $rows->fetchAssociative()) {
$result[(int)$row['fileid']] = $row;
}
$rows->closeCursor();
}
$rows = $qb->runAcrossAllShards()
->executeQuery();
while ($row = $rows->fetchAssociative()) {
$result[(int)$row['fileid']] = $row;
}
$rows->closeCursor();
return $result;
}
@ -338,20 +336,18 @@ class LocalPreviewStorage implements IPreviewStorage {
}
$result = [];
$qb = $this->connection->getTypedQueryBuilder();
$qb->selectColumns('fileid', 'storage', 'etag', 'mimetype', 'parent', 'path_hash')
->from('filecache');
foreach (array_chunk($pathHashes, 1000) as $chunk) {
$qb->andWhere(
$qb->expr()->in('path_hash', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_STR_ARRAY))
);
$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();
while ($row = $rows->fetchAssociative()) {
$result[$row['path_hash']] = $row;
}
$rows->closeCursor();
}
$rows = $qb->runAcrossAllShards()
->executeQuery();
while ($row = $rows->fetchAssociative()) {
$result[$row['path_hash']] = $row;
}
$rows->closeCursor();
return $result;
}