use faster and less hungry foreach

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2020-11-27 18:22:59 +01:00 committed by backportbot[bot]
parent 250c7535cd
commit 213464afca
1 changed files with 8 additions and 10 deletions

View File

@ -55,7 +55,7 @@ use OCP\ILogger;
class Group_LDAP extends BackendUtility implements GroupInterface, IGroupLDAP, IGetDisplayNameBackend { class Group_LDAP extends BackendUtility implements GroupInterface, IGroupLDAP, IGetDisplayNameBackend {
protected $enabled = false; 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; protected $cachedGroupMembers;
/** @var string[] $cachedGroupsByMember array of groups with uid as key */ /** @var string[] $cachedGroupsByMember array of groups with uid as key */
protected $cachedGroupsByMember; protected $cachedGroupsByMember;
@ -177,12 +177,10 @@ class Group_LDAP extends BackendUtility implements GroupInterface, IGroupLDAP, I
} }
// now we cleanup the users array to get only dns // now we cleanup the users array to get only dns
$dns = array_reduce($users, function (array $carry, array $record) { $dns = [];
if (!in_array($carry, $record['dn'][0])) { foreach ($users as $record) {
$carry[$record['dn'][0]] = 1; $dns[$record['dn'][0]] = 1;
} }
return $carry;
}, []);
$members = array_keys($dns); $members = array_keys($dns);
break; break;