Skip to content

Commit cb7485e

Browse files
committed
Fix more than 1000 entries in queries exception in CardDavBackend
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
1 parent 4cdc890 commit cb7485e

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

apps/dav/lib/CardDAV/CardDavBackend.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,15 +1130,18 @@ private function searchByAddressBookIds(array $addressBookIds,
11301130
return (int)$match['cardid'];
11311131
}, $matches);
11321132

1133-
$query = $this->db->getQueryBuilder();
1134-
$query->select('c.addressbookid', 'c.carddata', 'c.uri')
1135-
->from($this->dbCardsTable, 'c')
1136-
->where($query->expr()->in('c.id', $query->createNamedParameter($matches, IQueryBuilder::PARAM_INT_ARRAY)));
1133+
$cards = [];
1134+
foreach (array_chunk($matches, 1000) as $matche) {
1135+
$query = $this->db->getQueryBuilder();
1136+
$query->select('c.addressbookid', 'c.carddata', 'c.uri')
1137+
->from($this->dbCardsTable, 'c')
1138+
->where($query->expr()->in('c.id', $query->createNamedParameter($matche, IQueryBuilder::PARAM_INT_ARRAY)));
11371139

1138-
$result = $query->execute();
1139-
$cards = $result->fetchAll();
1140+
$result = $query->execute();
1141+
$cards = array_merge($cards, $result->fetchAll());
1142+
$result->closeCursor();
1143+
}
11401144

1141-
$result->closeCursor();
11421145

11431146
return array_map(function ($array) {
11441147
$array['addressbookid'] = (int) $array['addressbookid'];

0 commit comments

Comments
 (0)