Skip to content

Commit affb400

Browse files
committed
perf: Don't fetch full group object in AuthorizedGroupMapper
This is very expensive when multiple group backends are enabled as we don't cache which groups is included in which backend unlike in the User Manager. Signed-off-by: Carl Schwan <carlschwan@kde.org>
1 parent b1edaaa commit affb400

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/private/Settings/AuthorizedGroupMapper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ public function findAllClassesForUser(IUser $user): array {
3636
$qb = $this->db->getQueryBuilder();
3737

3838
$groupManager = Server::get(IGroupManager::class);
39-
$groups = $groupManager->getUserGroups($user);
40-
if (count($groups) === 0) {
39+
$groupIds = $groupManager->getUserGroupIds($user);
40+
if (count($groupIds) === 0) {
4141
return [];
4242
}
4343

4444
/** @var list<string> $rows */
4545
$rows = $qb->select('class')
4646
->from($this->getTableName(), 'auth')
47-
->where($qb->expr()->in('group_id', array_map(static fn (IGroup $group) => $qb->createNamedParameter($group->getGID()), $groups), IQueryBuilder::PARAM_STR))
47+
->where($qb->expr()->in('group_id', $qb->createNamedParameter($groupIds, IQueryBuilder::PARAM_STR_ARRAY)))
4848
->executeQuery()
4949
->fetchFirstColumn();
5050

0 commit comments

Comments
 (0)