Skip to content

Commit a81b6be

Browse files
committed
fix: remove caching in fetchListOfGroups
When using nested groups without a memberof overlay, then fetchListOfGroups is called from getGroupsByMember without applying the group filter. In some setups, the "unfiltered" result is then written back to the group mapping table. That might cause random "An administrator removed you from group" activities. I was unable to replicate it locally, but we got the feedback that the random activities stopped with the patch applied. Ref: #42195 Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
1 parent 12ea0eb commit a81b6be

File tree

2 files changed

+1
-17
lines changed

2 files changed

+1
-17
lines changed

apps/user_ldap/lib/Access.php

-16
Original file line numberDiff line numberDiff line change
@@ -948,22 +948,6 @@ public function fetchListOfGroups(string $filter, array $attr, ?int $limit = nul
948948
}
949949
$groupRecords = $this->searchGroups($filter, $attr, $limit, $offset);
950950

951-
$listOfDNs = array_reduce($groupRecords, function ($listOfDNs, $entry) {
952-
$listOfDNs[] = $entry['dn'][0];
953-
return $listOfDNs;
954-
}, []);
955-
$idsByDn = $this->getGroupMapper()->getListOfIdsByDn($listOfDNs);
956-
957-
array_walk($groupRecords, function (array $record) use ($idsByDn) {
958-
$newlyMapped = false;
959-
$gid = $idsByDn[$record['dn'][0]] ?? null;
960-
if ($gid === null) {
961-
$gid = $this->dn2ocname($record['dn'][0], null, false, $newlyMapped, $record);
962-
}
963-
if (!$newlyMapped && is_string($gid)) {
964-
$this->cacheGroupExists($gid);
965-
}
966-
});
967951
$listOfGroups = $this->fetchList($groupRecords, $this->manyAttributes($attr));
968952
$this->connection->writeToCache($cacheKey, $listOfGroups);
969953
return $listOfGroups;

apps/user_ldap/tests/AccessTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ public function testFetchListOfGroupsKnown() {
659659
$this->groupMapper->expects($this->never())
660660
->method('getNameByDN');
661661

662-
$this->connection->expects($this->exactly(3))
662+
$this->connection->expects($this->exactly(1))
663663
->method('writeToCache');
664664

665665
$groups = $this->access->fetchListOfGroups($filter, $attributes);

0 commit comments

Comments
 (0)