Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove caching in fetchListOfGroups #47513

Merged
merged 2 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions apps/user_ldap/lib/Access.php
Original file line number Diff line number Diff line change
Expand Up @@ -958,22 +958,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): void {
$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;
Expand Down
2 changes: 1 addition & 1 deletion apps/user_ldap/tests/AccessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ public function testFetchListOfGroupsKnown(): void {
$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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ Feature: LDAP
| ldapAttributesForUserSearch | employeeNumber |
| useMemberOfToDetectMembership | 1 |
And parameter "shareapi_only_share_with_group_members" of app "core" is set to "yes"
And invoking occ with "ldap:check-group cn=Orcharding,ou=OtherGroups,dc=nextcloud,dc=ci --update"
And As an "alice"
When getting sharees for
# "5" is part of the employee number of some LDAP records
Expand All @@ -162,4 +163,3 @@ Feature: LDAP
And "users" sharees returned are
| Elisa | 0 | elisa |
And "exact groups" sharees returned is empty

Loading