]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(provisioning_api): Fix getting disabled users for group admins backport/48766/stable28 48967/head
authorCôme Chilliet <come.chilliet@nextcloud.com>
Thu, 17 Oct 2024 13:44:42 +0000 (15:44 +0200)
committerFerdinand Thiessen <opensource@fthiessen.de>
Wed, 30 Oct 2024 18:32:25 +0000 (19:32 +0100)
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
apps/provisioning_api/lib/Controller/UsersController.php
apps/provisioning_api/tests/Controller/UsersControllerTest.php

index e1c60f3eb677cbfa741102b175250861f46f3b6b..ee8dcf9fb293451d5baf54a5b844fced63bc334e 100644 (file)
@@ -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 = [];
index 56de45ba2d612a14d52f19d6c11e21c31a18dbab..cfb7f2d9543a3e0ebcf62540a4e8557da28c6abe 100644 (file)
@@ -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();