From 13bfd8b292168fec6df2f99f66a96e19650bd138 Mon Sep 17 00:00:00 2001 From: Benjamin Gaussorgues Date: Mon, 22 Sep 2025 11:12:06 +0200 Subject: [PATCH] chore: add chunked queries on `occ sharing:delete-orphan-shares` Signed-off-by: Benjamin Gaussorgues --- apps/files_sharing/lib/OrphanHelper.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/files_sharing/lib/OrphanHelper.php b/apps/files_sharing/lib/OrphanHelper.php index ca8c198667b9d..f95622ed371c9 100644 --- a/apps/files_sharing/lib/OrphanHelper.php +++ b/apps/files_sharing/lib/OrphanHelper.php @@ -39,8 +39,13 @@ public function isShareValid(string $owner, int $fileId): bool { public function deleteShares(array $ids): void { $query = $this->connection->getQueryBuilder(); $query->delete('share') - ->where($query->expr()->in('id', $query->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY))); - $query->executeStatement(); + ->where($query->expr()->in('id', $query->createParameter('ids'))); + + $idsChunks = array_chunk($ids, 500); + foreach ($idsChunks as $idsChunk) { + $query->setParameter('ids', $idsChunk, IQueryBuilder::PARAM_INT_ARRAY) + ->executeStatement(); + } } public function fileExists(int $fileId): bool {