]> source.dussan.org Git - nextcloud-server.git/commitdiff
Build query once instead of in-loop 32912/head
authorCôme Chilliet <come.chilliet@nextcloud.com>
Thu, 7 Sep 2023 15:07:47 +0000 (17:07 +0200)
committerCôme Chilliet <come.chilliet@nextcloud.com>
Thu, 7 Sep 2023 15:07:47 +0000 (17:07 +0200)
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
lib/private/Group/Database.php

index 20e56a03d0adfa5bb75d61ddb6d44a6091a23800..55792ce1dff19b7075a99edf55dfb574ffc99919 100644 (file)
@@ -352,12 +352,13 @@ class Database extends ABackend implements
                        }
                }
 
-               foreach (array_chunk($notFoundGids, 1000) as $chunk) {
-                       $qb = $this->dbConn->getQueryBuilder();
-                       $result = $qb->select('gid', 'displayname')
+               $qb = $this->dbConn->getQueryBuilder();
+               $qb->select('gid', 'displayname')
                                ->from('groups')
-                               ->where($qb->expr()->in('gid', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_STR_ARRAY)))
-                               ->executeQuery();
+                               ->where($qb->expr()->in('gid', $qb->createParameter('ids')));
+               foreach (array_chunk($notFoundGids, 1000) as $chunk) {
+                       $qb->setParameter('ids', $chunk, IQueryBuilder::PARAM_STR_ARRAY);
+                       $result = $qb->executeQuery();
                        while ($row = $result->fetch()) {
                                $this->groupCache[(string)$row['gid']] = [
                                        'displayname' => (string)$row['displayname'],