Patch to optimize for large installations (>5000 users >20000 groups) where subadmins have access to many of groups (>250)

- UsersController:editUser() calls isUserAccessible() even if the user is admin

This fix reduces API calls to editUser (ex change locale/display name) from >2 minutes (!) to ~3 seconds per call in average.

Signed-off-by: Mikael Hammarin <mikael@try2.se>
This commit is contained in:
Mikael Hammarin 2019-10-28 15:48:46 +01:00 committed by Joas Schilling
parent 39f6f1ba34
commit 6ffde74928
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
2 changed files with 3 additions and 2 deletions

View File

@ -504,8 +504,8 @@ class UsersController extends AUserData {
} else { } else {
// Check if admin / subadmin // Check if admin / subadmin
$subAdminManager = $this->groupManager->getSubAdmin(); $subAdminManager = $this->groupManager->getSubAdmin();
if ($subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser) if ($this->groupManager->isAdmin($currentLoggedInUser->getUID())
|| $this->groupManager->isAdmin($currentLoggedInUser->getUID())) { || $subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
// They have permissions over the user // They have permissions over the user
$permittedFields[] = 'display'; $permittedFields[] = 'display';
$permittedFields[] = AccountManager::PROPERTY_DISPLAYNAME; $permittedFields[] = AccountManager::PROPERTY_DISPLAYNAME;

View File

@ -255,6 +255,7 @@ class SubAdmin extends PublicEmitter implements ISubAdmin {
if ($this->groupManager->isAdmin($user->getUID())) { if ($this->groupManager->isAdmin($user->getUID())) {
return false; return false;
} }
$accessibleGroups = $this->getSubAdminsGroups($subadmin); $accessibleGroups = $this->getSubAdminsGroups($subadmin);
foreach ($accessibleGroups as $accessibleGroup) { foreach ($accessibleGroups as $accessibleGroup) {
if ($accessibleGroup->inGroup($user)) { if ($accessibleGroup->inGroup($user)) {