diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2023-06-22 21:46:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-22 21:46:03 +0200 |
commit | 2e81a1d839359700dc3bad749191272f2bf49546 (patch) | |
tree | 0c5ab048b1b26227f7d55a5d20fa1a1e6363d4f8 /apps/user_ldap | |
parent | 7fa941e76f67b3848ea3fcea4f81f3df51d14c93 (diff) | |
parent | b980722e89fe8b9b1a312a2ef5de8dea7b9f663e (diff) | |
download | nextcloud-server-2e81a1d839359700dc3bad749191272f2bf49546.tar.gz nextcloud-server-2e81a1d839359700dc3bad749191272f2bf49546.zip |
Merge pull request #38457 from nextcloud/fix/improve-ldap-offset-search-perf
Use default page size for jumping to desired offset
Diffstat (limited to 'apps/user_ldap')
-rw-r--r-- | apps/user_ldap/lib/Access.php | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php index 3edeabda747..3fbb003ed51 100644 --- a/apps/user_ldap/lib/Access.php +++ b/apps/user_ldap/lib/Access.php @@ -1993,8 +1993,15 @@ class Access extends LDAPUtility { // no cookie known from a potential previous search. We need // to start from 0 to come to the desired page. cookie value // of '0' is valid, because 389ds - $reOffset = ($offset - $pageSize) < 0 ? 0 : $offset - $pageSize; - $this->search($filter, $base, $attr, $pageSize, $reOffset, true); + $defaultPageSize = (int)$this->connection->ldapPagingSize; + if ($offset < $defaultPageSize) { + /* Make a search with offset as page size and dismiss the result, to init the cookie */ + $this->search($filter, $base, $attr, $offset, 0, true); + } else { + /* Make a search for previous page and dismiss the result, to init the cookie */ + $reOffset = $offset - $defaultPageSize; + $this->search($filter, $base, $attr, $defaultPageSize, $reOffset, true); + } if (!$this->hasMoreResults()) { // when the cookie is reset with != 0 offset, there are no further // results, so stop. |