Skip to content

Commit 8e69237

Browse files
CarlSchwanChristophWurst
authored andcommitted
Don't recreate sql query each time
Signed-off-by: Carl Schwan <carl@carlschwan.eu> Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
1 parent 13366f4 commit 8e69237

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

apps/dav/lib/CardDAV/CardDavBackend.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,18 +1111,18 @@ private function searchByAddressBookIds(array $addressBookIds,
11111111
}, $matches);
11121112

11131113
$cards = [];
1114-
foreach (array_chunk($matches, 1000) as $matche) {
1115-
$query = $this->db->getQueryBuilder();
1116-
$query->select('c.addressbookid', 'c.carddata', 'c.uri')
1117-
->from($this->dbCardsTable, 'c')
1118-
->where($query->expr()->in('c.id', $query->createNamedParameter($matche, IQueryBuilder::PARAM_INT_ARRAY)));
1114+
$query = $this->db->getQueryBuilder();
1115+
$query->select('c.addressbookid', 'c.carddata', 'c.uri')
1116+
->from($this->dbCardsTable, 'c')
1117+
->where($query->expr()->in('c.id', $query->createParameter('matches')));
11191118

1119+
foreach (array_chunk($matches, 1000) as $matchesChunk) {
1120+
$query->setParameter('matches', $matchesChunk, IQueryBuilder::PARAM_INT_ARRAY);
11201121
$result = $query->execute();
11211122
$cards = array_merge($cards, $result->fetchAll());
11221123
$result->closeCursor();
11231124
}
11241125

1125-
11261126
return array_map(function ($array) {
11271127
$array['addressbookid'] = (int) $array['addressbookid'];
11281128
$modified = false;

0 commit comments

Comments
 (0)