summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2020-11-27 18:22:59 +0100
committerArthur Schiwon <blizzz@arthur-schiwon.de>2020-11-27 18:38:08 +0100
commit1f40ecca86d2c024116092f23ae8dbc5e50aa26d (patch)
treeb808f3ebad870035864bbc409013b3a34210ed92 /apps/user_ldap/lib
parent594370e2f2caa931e5a56a334ff2ea5d33da7eb7 (diff)
downloadnextcloud-server-1f40ecca86d2c024116092f23ae8dbc5e50aa26d.tar.gz
nextcloud-server-1f40ecca86d2c024116092f23ae8dbc5e50aa26d.zip
use faster and less hungry foreach
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r--apps/user_ldap/lib/Group_LDAP.php18
1 files changed, 8 insertions, 10 deletions
diff --git a/apps/user_ldap/lib/Group_LDAP.php b/apps/user_ldap/lib/Group_LDAP.php
index f1f6f946152..9cedbbadf56 100644
--- a/apps/user_ldap/lib/Group_LDAP.php
+++ b/apps/user_ldap/lib/Group_LDAP.php
@@ -55,7 +55,7 @@ use OCP\ILogger;
class Group_LDAP extends BackendUtility implements GroupInterface, IGroupLDAP, IGetDisplayNameBackend {
protected $enabled = false;
- /** @var string[] $cachedGroupMembers array of users with gid as key */
+ /** @var string[][] $cachedGroupMembers array of users with gid as key */
protected $cachedGroupMembers;
/** @var string[] $cachedGroupsByMember array of groups with uid as key */
protected $cachedGroupsByMember;
@@ -168,23 +168,21 @@ class Group_LDAP extends BackendUtility implements GroupInterface, IGroupLDAP, I
$users = array_merge($users, $search);
}
}
-
+
if (count($filterParts) > 0) {
// if there are filterParts left we need to add their result
$filter = $this->access->combineFilterWithOr($filterParts);
$search = $this->access->fetchListOfUsers($filter, $requestAttributes, count($filterParts));
$users = array_merge($users, $search);
}
-
+
// now we cleanup the users array to get only dns
- $dns = array_reduce($users, function (array $carry, array $record) {
- if (!in_array($carry, $record['dn'][0])) {
- $carry[$record['dn'][0]] = 1;
- }
- return $carry;
- }, []);
+ $dns = [];
+ foreach ($users as $record) {
+ $dns[$record['dn'][0]] = 1;
+ }
$members = array_keys($dns);
-
+
break;
}