From d62643b43ea7e8d106fc416c36988621694ce3cf Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=B4me=20Chilliet?= Date: Mon, 13 Mar 2023 16:05:41 +0100 Subject: [PATCH] Do not send a pagination control with size = 0 if cookie is empty MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- apps/user_ldap/lib/LDAP.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/apps/user_ldap/lib/LDAP.php b/apps/user_ldap/lib/LDAP.php index 5730907b653..41a6f651f3b 100644 --- a/apps/user_ldap/lib/LDAP.php +++ b/apps/user_ldap/lib/LDAP.php @@ -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]) ) { -- 2.39.5