Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix more than 1000 entries in queries exception in CardDavBackend
Signed-off-by: Carl Schwan <[email protected]>
  • Loading branch information
CarlSchwan committed Feb 21, 2022
commit cb7485e7640497c29423e72fba5c47a26e84e811
17 changes: 10 additions & 7 deletions apps/dav/lib/CardDAV/CardDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -1130,15 +1130,18 @@ private function searchByAddressBookIds(array $addressBookIds,
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'];
Expand Down