]> source.dussan.org Git - nextcloud-server.git/commitdiff
Do not send a pagination control with size = 0 if cookie is empty 37233/head
authorCôme Chilliet <come.chilliet@nextcloud.com>
Mon, 13 Mar 2023 15:05:41 +0000 (16:05 +0100)
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>
Wed, 15 Mar 2023 13:47:21 +0000 (13:47 +0000)
It only makes sense to send a pagination control with size 0 with a
 cookie to abandon a paged search.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
apps/user_ldap/lib/LDAP.php

index 5730907b65362da6ffa2a36adea10c6aeb2c20f2..41a6f651f3bf0e9cf4a7fd5a10e724d4927b272f 100644 (file)
@@ -190,14 +190,18 @@ class LDAP implements ILDAPWrapper {
         * {@inheritDoc}
         */
        public function search($link, $baseDN, $filter, $attr, $attrsOnly = 0, $limit = 0, int $pageSize = 0, string $cookie = '') {
-               $serverControls = [[
-                       'oid' => LDAP_CONTROL_PAGEDRESULTS,
-                       'value' => [
-                               'size' => $pageSize,
-                               'cookie' => $cookie,
-                       ],
-                       'iscritical' => false,
-               ]];
+               if ($pageSize > 0 || $cookie !== '') {
+                       $serverControls = [[
+                               'oid' => LDAP_CONTROL_PAGEDRESULTS,
+                               'value' => [
+                                       'size' => $pageSize,
+                                       'cookie' => $cookie,
+                               ],
+                               'iscritical' => false,
+                       ]];
+               } else {
+                       $serverControls = [];
+               }
 
                $oldHandler = set_error_handler(function ($no, $message, $file, $line) use (&$oldHandler) {
                        if (strpos($message, 'Partial search results returned: Sizelimit exceeded') !== false) {
@@ -387,7 +391,7 @@ class LDAP implements ILDAPWrapper {
                if ($this->isResource($this->curArgs[0])) {
                        $resource = $this->curArgs[0];
                } elseif (
-                          $functionName === 'ldap_search'
+                       $functionName === 'ldap_search'
                        && is_array($this->curArgs[0])
                        && $this->isResource($this->curArgs[0][0])
                ) {