diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-02-19 13:26:03 +0100 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2022-03-11 16:03:23 +0000 |
commit | f7557d84421563a426475bec4716f3d046424ab2 (patch) | |
tree | 23f170d556cd86ea5ad6dadf9ed9dff23dc9d0da | |
parent | 0d3c19c6aa76c7479fbb4b3784ae20b5b7b7ed89 (diff) | |
download | nextcloud-server-f7557d84421563a426475bec4716f3d046424ab2.tar.gz nextcloud-server-f7557d84421563a426475bec4716f3d046424ab2.zip |
Fix more than 1000 entries in queries exception in CardDavBackend
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
-rw-r--r-- | apps/dav/lib/CardDAV/CardDavBackend.php | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php index 3e360fb2e41..98e85096b3b 100644 --- a/apps/dav/lib/CardDAV/CardDavBackend.php +++ b/apps/dav/lib/CardDAV/CardDavBackend.php @@ -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']; |