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
Prev Previous commit
Don't recreate sql query each time
Signed-off-by: Carl Schwan <[email protected]>
  • Loading branch information
CarlSchwan authored and backportbot[bot] committed Mar 11, 2022
commit 04ad3ba86396611c1fe53a66a41e72ed38dcda9a
16 changes: 8 additions & 8 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 @@ -1131,18 +1131,18 @@ private function searchByAddressBookIds(array $addressBookIds,
}, $matches);

$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)));
$query = $this->db->getQueryBuilder();
$query->select('c.addressbookid', 'c.carddata', 'c.uri')
->from($this->dbCardsTable, 'c')
->where($query->expr()->in('c.id', $query->createParameter('matches')));

$result = $query->execute();
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'];
$modified = false;
Expand Down