]> source.dussan.org Git - nextcloud-server.git/commitdiff
Limit parameter count per query in Cache.removeChildren
authorSijmen Schoon <me@sijmenschoon.nl>
Sun, 17 Oct 2021 17:08:27 +0000 (19:08 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Mon, 1 Nov 2021 11:27:36 +0000 (11:27 +0000)
Signed-off-by: Sijmen Schoon <me@sijmenschoon.nl>
lib/private/Files/Cache/Cache.php

index 3ede9fac61884c326c76a8f73fede719d2190db6..7e3cfcfda5d7c1c24152e93bfdb63fcc78a805a0 100644 (file)
@@ -585,10 +585,13 @@ class Cache implements ICache {
                                return $cacheEntry->getId();
                        }, $children);
 
-                       $query = $this->getQueryBuilder();
-                       $query->delete('filecache_extended')
-                               ->where($query->expr()->in('fileid', $query->createNamedParameter($childIds, IQueryBuilder::PARAM_INT_ARRAY)));
-                       $query->execute();
+                       $childIdChunks = array_chunk($childIds, 2048);
+                       foreach ($childIdChunks as $childIdChunk) {
+                               $query = $this->getQueryBuilder();
+                               $query->delete('filecache_extended')
+                                       ->where($query->expr()->in('fileid', $query->createNamedParameter($childIdChunk, IQueryBuilder::PARAM_INT_ARRAY)));
+                               $query->execute();
+                       }
 
                        /** @var ICacheEntry[] $childFolders */
                        $childFolders = array_filter($children, function ($child) {
@@ -600,10 +603,13 @@ class Cache implements ICache {
                        }
                }
 
-               $query = $this->getQueryBuilder();
-               $query->delete('filecache')
-                       ->whereParentIn($parentIds);
-               $query->execute();
+               $parentIdChunks = array_chunk($parentIds, 2048);
+               foreach ($parentIdChunks as $parentIdChunk) {
+                       $query = $this->getQueryBuilder();
+                       $query->delete('filecache')
+                               ->whereParentIn($parentIdChunk);
+                       $query->execute();
+               }
        }
 
        /**