]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix more than 1000 entries in queries exception in CardDavBackend
authorCarl Schwan <carl@carlschwan.eu>
Sat, 19 Feb 2022 12:26:03 +0000 (13:26 +0100)
committerCarl Schwan <carl@carlschwan.eu>
Mon, 21 Feb 2022 13:30:00 +0000 (14:30 +0100)
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
apps/dav/lib/CardDAV/CardDavBackend.php

index 3e360fb2e414dddd14569de61dc43eab478144dc..98e85096b3bf7f66bdac73441a71cc7545d6d183 100644 (file)
@@ -1130,15 +1130,18 @@ class CardDavBackend implements BackendInterface, SyncSupport {
                        return (int)$match['cardid'];
                }, $matches);
 
-               $query = $this->db->getQueryBuilder();
-               $query->select('c.addressbookid', 'c.carddata', 'c.uri')
-                       ->from($this->dbCardsTable, 'c')
-                       ->where($query->expr()->in('c.id', $query->createNamedParameter($matches, IQueryBuilder::PARAM_INT_ARRAY)));
+               $cards = [];
+               foreach (array_chunk($matches, 1000) as $matche) {
+                       $query = $this->db->getQueryBuilder();
+                       $query->select('c.addressbookid', 'c.carddata', 'c.uri')
+                               ->from($this->dbCardsTable, 'c')
+                               ->where($query->expr()->in('c.id', $query->createNamedParameter($matche, IQueryBuilder::PARAM_INT_ARRAY)));
 
-               $result = $query->execute();
-               $cards = $result->fetchAll();
+                       $result = $query->execute();
+                       $cards = array_merge($cards, $result->fetchAll());
+                       $result->closeCursor();
+               }
 
-               $result->closeCursor();
 
                return array_map(function ($array) {
                        $array['addressbookid'] = (int) $array['addressbookid'];