]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix paged search when offset is not a multiple of default page size 38457/head
authorCôme Chilliet <come.chilliet@nextcloud.com>
Tue, 20 Jun 2023 14:13:59 +0000 (16:13 +0200)
committerCôme Chilliet <come.chilliet@nextcloud.com>
Tue, 20 Jun 2023 14:13:59 +0000 (16:13 +0200)
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
apps/user_ldap/lib/Access.php

index a6c48f383d22d135e22d6a1ed8b883ba1ea72586..465a9d5cc16736540daa6498cfb6f101d5ea626f 100644 (file)
@@ -1994,8 +1994,14 @@ class Access extends LDAPUtility {
                                // to start from 0 to come to the desired page. cookie value
                                // of '0' is valid, because 389ds
                                $defaultPageSize = (int)$this->connection->ldapPagingSize;
-                               $reOffset = ($offset - $defaultPageSize) < 0 ? 0 : $offset - $defaultPageSize;
-                               $this->search($filter, $base, $attr, $defaultPageSize, $reOffset, true);
+                               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.