diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2021-12-12 14:14:16 +0100 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2022-10-20 12:08:34 +0200 |
commit | 5647093319e6083a4571651f7491c5aa50df4a03 (patch) | |
tree | 4e46d11e23e128b25486b047784801fbecd24e98 /apps/user_ldap/lib | |
parent | ad2fdbe3776dc2d25c646d37b9cff448d5fdf326 (diff) | |
download | nextcloud-server-5647093319e6083a4571651f7491c5aa50df4a03.tar.gz nextcloud-server-5647093319e6083a4571651f7491c5aa50df4a03.zip |
Cache intermediates
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Co-authored-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r-- | apps/user_ldap/lib/Access.php | 6 | ||||
-rw-r--r-- | apps/user_ldap/lib/Group_LDAP.php | 8 |
2 files changed, 13 insertions, 1 deletions
diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php index cec192721a5..7ad6552780c 100644 --- a/apps/user_ldap/lib/Access.php +++ b/apps/user_ldap/lib/Access.php @@ -511,6 +511,11 @@ class Access extends LDAPUtility { * @throws \Exception */ public function dn2ocname($fdn, $ldapName = null, $isUser = true, &$newlyMapped = null, array $record = null) { + static $intermediates = []; + if (isset($intermediates[($isUser ? 'user-' : 'group-') . $fdn])) { + return false; // is a known intermediate + } + $newlyMapped = false; if ($isUser) { $mapper = $this->getUserMapper(); @@ -546,6 +551,7 @@ class Access extends LDAPUtility { $ldapName = $this->readAttribute($fdn, $nameAttribute, $filter); if (!isset($ldapName[0]) || empty($ldapName[0])) { $this->logger->debug('No or empty name for ' . $fdn . ' with filter ' . $filter . '.', ['app' => 'user_ldap']); + $intermediates[($isUser ? 'user-' : 'group-') . $fdn] = true; return false; } $ldapName = $ldapName[0]; diff --git a/apps/user_ldap/lib/Group_LDAP.php b/apps/user_ldap/lib/Group_LDAP.php index b0d5909fd81..aa4c6572869 100644 --- a/apps/user_ldap/lib/Group_LDAP.php +++ b/apps/user_ldap/lib/Group_LDAP.php @@ -363,7 +363,13 @@ class Group_LDAP extends BackendUtility implements GroupInterface, IGroupLDAP, I // Prevent loops continue; } - $fetched = $fetcher($record); + + $cacheKey = 'walkNestedGroups_' . $recordDN; + $fetched = $this->access->connection->getFromCache($cacheKey); + if ($fetched === null) { + $fetched = $fetcher($record); + $fetched = $this->access->connection->writeToCache($cacheKey, $fetched); + } $list = array_merge($list, $fetched); if (!isset($seen[$recordDN]) || is_bool($seen[$recordDN]) && is_array($record)) { $seen[$recordDN] = $record; |