From d18bb7e9bb0b350f65157f648e0c5c8c8f0282cf Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=B4me=20Chilliet?= Date: Thu, 7 Sep 2023 17:07:47 +0200 Subject: [PATCH] Build query once instead of in-loop MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- lib/private/Group/Database.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/private/Group/Database.php b/lib/private/Group/Database.php index 20e56a03d0a..55792ce1dff 100644 --- a/lib/private/Group/Database.php +++ b/lib/private/Group/Database.php @@ -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'], -- 2.39.5