diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2023-09-07 17:07:47 +0200 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2023-09-07 17:07:47 +0200 |
commit | d18bb7e9bb0b350f65157f648e0c5c8c8f0282cf (patch) | |
tree | 71e8db1d2e938a08b228c729cc43ca92773a7dd1 /lib/private/Group | |
parent | 35069ad86a96923b0e39c897bb839058de4b4b34 (diff) | |
download | nextcloud-server-d18bb7e9bb0b350f65157f648e0c5c8c8f0282cf.tar.gz nextcloud-server-d18bb7e9bb0b350f65157f648e0c5c8c8f0282cf.zip |
Build query once instead of in-loop
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib/private/Group')
-rw-r--r-- | lib/private/Group/Database.php | 11 |
1 files 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'], |