Skip to content

Commit 2194dee

Browse files
CarlSchwanAndyScherzinger
authored andcommitted
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 f4f120c commit 2194dee

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

lib/private/Settings/AuthorizedGroupMapper.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use OCP\DB\Exception;
1212
use OCP\DB\QueryBuilder\IQueryBuilder;
1313
use OCP\IDBConnection;
14-
use OCP\IGroup;
1514
use OCP\IGroupManager;
1615
use OCP\IUser;
1716

@@ -31,16 +30,14 @@ public function findAllClassesForUser(IUser $user): array {
3130

3231
/** @var IGroupManager $groupManager */
3332
$groupManager = \OC::$server->get(IGroupManager::class);
34-
$groups = $groupManager->getUserGroups($user);
35-
if (count($groups) === 0) {
33+
$groupIds = $groupManager->getUserGroupIds($user);
34+
if (count($groupIds) === 0) {
3635
return [];
3736
}
3837

3938
$result = $qb->select('class')
4039
->from($this->getTableName(), 'auth')
41-
->where($qb->expr()->in('group_id', array_map(function (IGroup $group) use ($qb) {
42-
return $qb->createNamedParameter($group->getGID());
43-
}, $groups), IQueryBuilder::PARAM_STR))
40+
->where($qb->expr()->in('group_id', $qb->createNamedParameter($groupIds, IQueryBuilder::PARAM_STR_ARRAY)))
4441
->executeQuery();
4542

4643
$classes = [];

0 commit comments

Comments
 (0)