From 7ef425b78927690407a0050af99d61eb08bc5101 Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Thu, 8 Aug 2024 16:00:02 +0200 Subject: [PATCH 1/2] fix: remove group exist cache in fetchListOfGroups fetchListOfGroups might be called without the group filter and therefore may cache invalid groups. Signed-off-by: Daniel Kesselberg --- apps/user_ldap/lib/Access.php | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php index b8bee8a3ef7cb..344ffa4a709df 100644 --- a/apps/user_ldap/lib/Access.php +++ b/apps/user_ldap/lib/Access.php @@ -873,22 +873,6 @@ public function fetchListOfGroups(string $filter, array $attr, ?int $limit = nul } $groupRecords = $this->searchGroups($filter, $attr, $limit, $offset); - $listOfDNs = array_reduce($groupRecords, function ($listOfDNs, $entry) { - $listOfDNs[] = $entry['dn'][0]; - return $listOfDNs; - }, []); - $idsByDn = $this->getGroupMapper()->getListOfIdsByDn($listOfDNs); - - array_walk($groupRecords, function (array $record) use ($idsByDn) { - $newlyMapped = false; - $gid = $idsByDn[$record['dn'][0]] ?? null; - if ($gid === null) { - $gid = $this->dn2ocname($record['dn'][0], null, false, $newlyMapped, $record); - } - if (!$newlyMapped && is_string($gid)) { - $this->cacheGroupExists($gid); - } - }); $listOfGroups = $this->fetchList($groupRecords, $this->manyAttributes($attr)); $this->connection->writeToCache($cacheKey, $listOfGroups); return $listOfGroups; From 7418cfe3eab95f509efc89f9f775060f921d88dc Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Thu, 8 Aug 2024 16:19:53 +0200 Subject: [PATCH 2/2] fixup! fix: remove group exist cache in fetchListOfGroups Signed-off-by: Daniel Kesselberg --- apps/user_ldap/tests/AccessTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/user_ldap/tests/AccessTest.php b/apps/user_ldap/tests/AccessTest.php index 941aa51fc3122..595189dcc02ec 100644 --- a/apps/user_ldap/tests/AccessTest.php +++ b/apps/user_ldap/tests/AccessTest.php @@ -658,7 +658,7 @@ public function testFetchListOfGroupsKnown() { $this->groupMapper->expects($this->never()) ->method('getNameByDN'); - $this->connection->expects($this->exactly(3)) + $this->connection->expects($this->exactly(1)) ->method('writeToCache'); $groups = $this->access->fetchListOfGroups($filter, $attributes);