diff options
author | blizzz <blizzz@arthur-schiwon.de> | 2022-03-16 13:13:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-16 13:13:38 +0100 |
commit | 1be5725240e33fbd99cebc94ae1385171d80cada (patch) | |
tree | 5c15c3833a4518672b7c8a2ac36b7e165afca127 | |
parent | 0932959634d5fe72b5d6762bbe66ce63c068360c (diff) | |
parent | b7838c77900f1967da2d9b38d64399e330223a5e (diff) | |
download | nextcloud-server-1be5725240e33fbd99cebc94ae1385171d80cada.tar.gz nextcloud-server-1be5725240e33fbd99cebc94ae1385171d80cada.zip |
Merge pull request #31550 from nextcloud/backport/31274/stable23
[stable23] Fix more than 1000 entries in queries exception in CardDavBackend
-rw-r--r-- | apps/dav/lib/CardDAV/CardDavBackend.php | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php index 3e360fb2e41..1c1754ff752 100644 --- a/apps/dav/lib/CardDAV/CardDavBackend.php +++ b/apps/dav/lib/CardDAV/CardDavBackend.php @@ -139,7 +139,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { ->from('addressbooks') ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))); - $result = $query->execute(); + $result = $query->executeQuery(); $column = (int) $result->fetchOne(); $result->closeCursor(); return $column; @@ -1130,15 +1130,18 @@ class CardDavBackend implements BackendInterface, SyncSupport { return (int)$match['cardid']; }, $matches); + $cards = []; $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))); - - $result = $query->execute(); - $cards = $result->fetchAll(); + ->where($query->expr()->in('c.id', $query->createParameter('matches'))); - $result->closeCursor(); + foreach (array_chunk($matches, 1000) as $matchesChunk) { + $query->setParameter('matches', $matchesChunk, IQueryBuilder::PARAM_INT_ARRAY); + $result = $query->executeQuery(); + $cards = array_merge($cards, $result->fetchAll()); + $result->closeCursor(); + } return array_map(function ($array) { $array['addressbookid'] = (int) $array['addressbookid']; |