]> source.dussan.org Git - nextcloud-server.git/commitdiff
Don't recreate sql query each time 31274/head
authorCarl Schwan <carl@carlschwan.eu>
Thu, 10 Mar 2022 14:10:08 +0000 (15:10 +0100)
committerCarl Schwan <carl@carlschwan.eu>
Thu, 10 Mar 2022 14:10:08 +0000 (15:10 +0100)
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
apps/dav/lib/CardDAV/CardDavBackend.php

index 98e85096b3bf7f66bdac73441a71cc7545d6d183..1c1754ff752f35c50f640a46119e1025fd3727d0 100644 (file)
@@ -139,7 +139,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
                        ->from('addressbooks')
                        ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
 
-               $result = $query->execute();
+               $result = $query->executeQuery();
                $column = (int) $result->fetchOne();
                $result->closeCursor();
                return $column;
@@ -1131,18 +1131,18 @@ class CardDavBackend implements BackendInterface, SyncSupport {
                }, $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;