Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-07-18 11:06:41 +0300
committerCarl Schwan <carl@carlschwan.eu>2022-10-20 13:09:06 +0300
commite0fbd3984003164738ffc9d727314c718867b59e (patch)
tree176db8d874d8005805396c1323746d0f38083a57
parent33be3f754a00d30021ede8a92aae15599b832f4a (diff)
Add back runtime cache for intermediate ldap read results
This is a small optimization that save a few LDAP queries Signed-off-by: Carl Schwan <carl@carlschwan.eu>
-rw-r--r--apps/user_ldap/lib/Group_LDAP.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/apps/user_ldap/lib/Group_LDAP.php b/apps/user_ldap/lib/Group_LDAP.php
index 272ceea5865..5bec38e30ee 100644
--- a/apps/user_ldap/lib/Group_LDAP.php
+++ b/apps/user_ldap/lib/Group_LDAP.php
@@ -245,8 +245,8 @@ class Group_LDAP extends BackendUtility implements GroupInterface, IGroupLDAP, I
if (isset($seen[$dnGroup])) {
return [];
}
- $seen[$dnGroup] = true;
$shouldCacheResult = count($seen) === 0;
+ $seen[$dnGroup] = true;
// used extensively in cron job, caching makes sense for nested groups
$cacheKey = '_groupMembers' . $dnGroup;
@@ -288,7 +288,15 @@ class Group_LDAP extends BackendUtility implements GroupInterface, IGroupLDAP, I
}
$allMembers = [];
- $members = $this->access->readAttribute($dnGroup, $this->access->connection->ldapGroupMemberAssocAttr);
+
+ /** @psalm-var array<string, string[]|bool> $rawMemberReads */
+ static $rawMemberReads = []; // runtime cache for intermediate ldap read results
+ $members = $rawMemberReads[$dnGroup] ?? null;
+ if ($members === null) {
+ $members = $this->access->readAttribute($dnGroup, $this->access->connection->ldapGroupMemberAssocAttr);
+ $rawMemberReads[$dnGroup] = $members;
+ }
+
if (is_array($members)) {
if ((int)$this->access->connection->ldapNestedGroups === 1) {
while ($recordDn = array_shift($members)) {