Skip to content

Commit 38327e4

Browse files
Merge pull request #54777 from nextcloud/perf/carddav/ungreedify-search
perf(carddav): ungreedify search result aggregation
2 parents d73537d + 4cf2203 commit 38327e4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

apps/dav/lib/CardDAV/CardDavBackend.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,7 @@ private function searchByAddressBookIds(array $addressBookIds,
12381238
return (int)$match['cardid'];
12391239
}, $matches);
12401240

1241-
$cards = [];
1241+
$cardResults = [];
12421242
$query = $this->db->getQueryBuilder();
12431243
$query->select('c.addressbookid', 'c.carddata', 'c.uri')
12441244
->from($this->dbCardsTable, 'c')
@@ -1247,10 +1247,11 @@ private function searchByAddressBookIds(array $addressBookIds,
12471247
foreach (array_chunk($matches, 1000) as $matchesChunk) {
12481248
$query->setParameter('matches', $matchesChunk, IQueryBuilder::PARAM_INT_ARRAY);
12491249
$result = $query->executeQuery();
1250-
$cards = array_merge($cards, $result->fetchAll());
1250+
$cardResults[] = $result->fetchAll();
12511251
$result->closeCursor();
12521252
}
12531253

1254+
$cards = array_merge(...$cardResults);
12541255
return array_map(function ($array) {
12551256
$array['addressbookid'] = (int)$array['addressbookid'];
12561257
$modified = false;

0 commit comments

Comments
 (0)