]> source.dussan.org Git - nextcloud-server.git/commitdiff
use faster and less hungry foreach
authorArthur Schiwon <blizzz@arthur-schiwon.de>
Fri, 27 Nov 2020 17:22:59 +0000 (18:22 +0100)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Tue, 15 Dec 2020 21:37:51 +0000 (21:37 +0000)
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
apps/user_ldap/lib/Group_LDAP.php

index f1f6f9461528cee0e9c5fa550e0d0cbd474184a0..9cedbbadf560edabeed28c64a23480e0047bcfc2 100644 (file)
@@ -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;
                }