Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable22] Fix more than 1000 entries in queries exception in CardDavBackend #31552

Merged
merged 2 commits into from
Mar 16, 2022
Merged
Changes from all commits
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
15 changes: 9 additions & 6 deletions apps/dav/lib/CardDAV/CardDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function getAddressBooksForUserCount($principalUri) {
->from('addressbooks')
->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));

$result = $query->execute();
$result = $query->executeQuery();
$column = (int) $result->fetchOne();
$result->closeCursor();
return $column;
Expand Down Expand Up @@ -1130,15 +1130,18 @@ private function searchByAddressBookIds(array $addressBookIds,
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'];
Expand Down