From: Côme Chilliet Date: Thu, 17 Oct 2024 13:44:42 +0000 (+0200) Subject: fix(provisioning_api): Fix getting disabled users for group admins X-Git-Tag: v28.0.12rc1~4^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fheads%2Fbackport%2F48766%2Fstable28;p=nextcloud-server.git fix(provisioning_api): Fix getting disabled users for group admins Signed-off-by: Côme Chilliet --- diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index e1c60f3eb67..ee8dcf9fb29 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -277,21 +277,21 @@ class UsersController extends AUserData { /* We have to handle offset ourselve for correctness */ $tempLimit = ($limit === null ? null : $limit + $offset); foreach ($subAdminOfGroups as $group) { - $users = array_merge( + $users = array_unique(array_merge( $users, array_map( fn (IUser $user): string => $user->getUID(), array_filter( - $group->searchUsers($search, ($tempLimit === null ? null : $tempLimit - count($users))), + $group->searchUsers($search), fn (IUser $user): bool => !$user->isEnabled() ) ) - ); + )); if (($tempLimit !== null) && (count($users) >= $tempLimit)) { break; } } - $users = array_slice($users, $offset); + $users = array_slice($users, $offset, $limit); } $usersDetails = []; diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php index 56de45ba2d6..cfb7f2d9543 100644 --- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php +++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php @@ -244,7 +244,7 @@ class UsersControllerTest extends TestCase { $this->assertEquals($expected, $this->api->getUsers('MyCustomSearch')->getData()); } - private function createUserMock(string $uid, bool $enabled): MockObject&IUser { + private function createUserMock(string $uid, bool $enabled): MockObject|IUser { $mockUser = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock();