Skip to content

Commit a6a3204

Browse files
authored
Merge pull request #55252 from nextcloud/chore/chunked_orphan_delete
2 parents 1a7f2f8 + 13bfd8b commit a6a3204

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

apps/files_sharing/lib/OrphanHelper.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,13 @@ public function isShareValid(string $owner, int $fileId): bool {
3939
public function deleteShares(array $ids): void {
4040
$query = $this->connection->getQueryBuilder();
4141
$query->delete('share')
42-
->where($query->expr()->in('id', $query->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY)));
43-
$query->executeStatement();
42+
->where($query->expr()->in('id', $query->createParameter('ids')));
43+
44+
$idsChunks = array_chunk($ids, 500);
45+
foreach ($idsChunks as $idsChunk) {
46+
$query->setParameter('ids', $idsChunk, IQueryBuilder::PARAM_INT_ARRAY)
47+
->executeStatement();
48+
}
4449
}
4550

4651
public function fileExists(int $fileId): bool {

0 commit comments

Comments
 (0)