aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2022-11-17 15:12:24 +0100
committerCôme Chilliet <come.chilliet@nextcloud.com>2022-11-17 15:12:24 +0100
commit9e1dd52c998ed7c9feb6ba9a1a64f0c6856fd8fa (patch)
tree460b443a8695045343015b3cdb485bd902903d23 /apps/user_ldap/lib
parent301af07e2f4cb506512899b7b4783db8b7975ee9 (diff)
downloadnextcloud-server-9e1dd52c998ed7c9feb6ba9a1a64f0c6856fd8fa.tar.gz
nextcloud-server-9e1dd52c998ed7c9feb6ba9a1a64f0c6856fd8fa.zip
Cache the fetched list of groups
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r--apps/user_ldap/lib/Access.php21
1 files changed, 14 insertions, 7 deletions
diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php
index a64c61f8139..6b12e0edc11 100644
--- a/apps/user_ldap/lib/Access.php
+++ b/apps/user_ldap/lib/Access.php
@@ -917,6 +917,11 @@ class Access extends LDAPUtility {
* @return array[]
*/
public function fetchListOfGroups(string $filter, array $attr, int $limit = null, int $offset = null): array {
+ $cacheKey = 'fetchListOfGroups_' . $filter . '_' . implode('-', $attr) . '_' . (string)$limit . '_' . (string)$offset;
+ $listOfGroups = $this->connection->getFromCache($cacheKey);
+ if (!is_null($listOfGroups)) {
+ return $listOfGroups;
+ }
$groupRecords = $this->searchGroups($filter, $attr, $limit, $offset);
$listOfDNs = array_reduce($groupRecords, function ($listOfDNs, $entry) {
@@ -935,7 +940,9 @@ class Access extends LDAPUtility {
$this->cacheGroupExists($gid);
}
});
- return $this->fetchList($groupRecords, $this->manyAttributes($attr));
+ $listOfGroups = $this->fetchList($groupRecords, $this->manyAttributes($attr));
+ $this->connection->writeToCache($cacheKey, $listOfGroups);
+ return $listOfGroups;
}
private function fetchList(array $list, bool $manyAttributes): array {
@@ -1985,12 +1992,12 @@ class Access extends LDAPUtility {
}
$this->logger->debug('Ready for a paged search', ['app' => 'user_ldap']);
return [true, $pageSize, $this->lastCookie];
- /* ++ Fixing RHDS searches with pages with zero results ++
- * We couldn't get paged searches working with our RHDS for login ($limit = 0),
- * due to pages with zero results.
- * So we added "&& !empty($this->lastCookie)" to this test to ignore pagination
- * if we don't have a previous paged search.
- */
+ /* ++ Fixing RHDS searches with pages with zero results ++
+ * We couldn't get paged searches working with our RHDS for login ($limit = 0),
+ * due to pages with zero results.
+ * So we added "&& !empty($this->lastCookie)" to this test to ignore pagination
+ * if we don't have a previous paged search.
+ */
} elseif ($this->lastCookie !== '') {
// a search without limit was requested. However, if we do use
// Paged Search once, we always must do it. This requires us to