aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Group
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2023-05-02 11:35:41 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2023-05-02 11:35:41 +0200
commit10296ba7e50ede8eee0ed18f477eb3e67bfd5878 (patch)
tree10c4bc603b7a75060bbf96e7e152fd35216740ef /lib/private/Group
parent876c162df831f70a9b4ed886f35c47c9c22df5ea (diff)
downloadnextcloud-server-10296ba7e50ede8eee0ed18f477eb3e67bfd5878.tar.gz
nextcloud-server-10296ba7e50ede8eee0ed18f477eb3e67bfd5878.zip
Fix tests, and fix Group::searchUsers to avoid duplicates
Also went back to searchUsers indexing the array by uid as it was the previous behavior and the IGroup phpdoc does not say anything about the keys. Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib/private/Group')
-rw-r--r--lib/private/Group/Group.php17
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/private/Group/Group.php b/lib/private/Group/Group.php
index 7f04e45de80..efc21ad7c0d 100644
--- a/lib/private/Group/Group.php
+++ b/lib/private/Group/Group.php
@@ -251,15 +251,15 @@ class Group implements IGroup {
$users = [];
foreach ($this->backends as $backend) {
if ($backend instanceof ISearchableGroupBackend) {
- $users = array_merge($users, array_values($backend->searchInGroup($this->gid, $search, $limit ?? -1, $offset ?? 0)));
+ $users += $backend->searchInGroup($this->gid, $search, $limit ?? -1, $offset ?? 0);
} else {
$userIds = $backend->usersInGroup($this->gid, $search, $limit ?? -1, $offset ?? 0);
$userManager = \OCP\Server::get(IUserManager::class);
- $userObjects = array_map(
- fn (string $userId): IUser => new LazyUser($userId, $userManager),
- $userIds
- );
- $users = array_merge($users, $userObjects);
+ foreach ($userIds as $userId) {
+ if (!isset($users[$userId])) {
+ $users[$userId] = new LazyUser($userId, $userManager);
+ }
+ }
}
if (!is_null($limit) and $limit <= 0) {
return $users;
@@ -375,10 +375,7 @@ class Group implements IGroup {
* @param string[] $userIds an array containing user IDs
* @return \OC\User\User[] an Array with the userId as Key and \OC\User\User as value
*/
- private function getVerifiedUsers($userIds) {
- if (!is_array($userIds)) {
- return [];
- }
+ private function getVerifiedUsers(array $userIds): array {
$users = [];
foreach ($userIds as $userId) {
$user = $this->userManager->get($userId);