From d790d45567d81b97fdee87e154bd230b03a1a20a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 25 Aug 2022 16:57:25 +0200 Subject: [PATCH] Remove dead code in paged result handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is only one paged result API now that PHP 7.2 is long dead. Starting by removing empty function calls. Signed-off-by: Côme Chilliet --- apps/user_ldap/lib/Access.php | 13 ++++------ apps/user_ldap/lib/ILDAPWrapper.php | 3 +-- apps/user_ldap/lib/LDAP.php | 15 +---------- apps/user_ldap/lib/PagedResults/IAdapter.php | 26 -------------------- apps/user_ldap/lib/PagedResults/Php73.php | 14 ----------- 5 files changed, 7 insertions(+), 64 deletions(-) diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php index cec192721a5..e56ceea4098 100644 --- a/apps/user_ldap/lib/Access.php +++ b/apps/user_ldap/lib/Access.php @@ -1996,12 +1996,9 @@ class Access extends LDAPUtility { //since offset = 0, this is a new search. We abandon other searches that might be ongoing. $this->abandonPagedSearch(); } - $pagedSearchOK = true === $this->invokeLDAPMethod( - 'controlPagedResult', $limit, false - ); - if ($pagedSearchOK) { - $this->logger->debug('Ready for a paged search', ['app' => 'user_ldap']); - } + $pagedSearchOK = true; + $this->invokeLDAPMethod('controlPagedResult', $limit, false); + $this->logger->debug('Ready for a paged search', ['app' => 'user_ldap']); /* ++ 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. @@ -2016,8 +2013,8 @@ class Access extends LDAPUtility { // in case someone set it to 0 … use 500, otherwise no results will // be returned. $pageSize = (int)$this->connection->ldapPagingSize > 0 ? (int)$this->connection->ldapPagingSize : 500; - $pagedSearchOK = $this->invokeLDAPMethod('controlPagedResult', - $pageSize, false); + $pagedSearchOK = true; + $this->invokeLDAPMethod('controlPagedResult', $pageSize, false); } return $pagedSearchOK; diff --git a/apps/user_ldap/lib/ILDAPWrapper.php b/apps/user_ldap/lib/ILDAPWrapper.php index e72d85ac2b9..1de871c66bd 100644 --- a/apps/user_ldap/lib/ILDAPWrapper.php +++ b/apps/user_ldap/lib/ILDAPWrapper.php @@ -58,9 +58,8 @@ interface ILDAPWrapper { * @param int $pageSize number of results per page * @param bool $isCritical Indicates whether the pagination is critical of not. * @param string $cookie structure sent by LDAP server - * @return bool true on success, false otherwise */ - public function controlPagedResult($link, $pageSize, $isCritical); + public function controlPagedResult($link, $pageSize, $isCritical): void; /** * Retrieve the LDAP pagination cookie diff --git a/apps/user_ldap/lib/LDAP.php b/apps/user_ldap/lib/LDAP.php index 545a09ca464..28664b2dda6 100644 --- a/apps/user_ldap/lib/LDAP.php +++ b/apps/user_ldap/lib/LDAP.php @@ -105,21 +105,8 @@ class LDAP implements ILDAPWrapper { /** * {@inheritDoc} */ - public function controlPagedResult($link, $pageSize, $isCritical) { - $fn = $this->pagedResultsAdapter->getRequestCallFunc(); + public function controlPagedResult($link, $pageSize, $isCritical): void { $this->pagedResultsAdapter->setRequestParameters($link, $pageSize, $isCritical); - if ($fn === null) { - return true; - } - - $this->preFunctionCall($fn, $this->pagedResultsAdapter->getRequestCallArgs($link)); - $result = $this->pagedResultsAdapter->requestCall($link); - - if ($this->isResultFalse($result)) { - $this->postFunctionCall(); - } - - return $result; } /** diff --git a/apps/user_ldap/lib/PagedResults/IAdapter.php b/apps/user_ldap/lib/PagedResults/IAdapter.php index 62a0d0440c5..504dd7eaa9d 100644 --- a/apps/user_ldap/lib/PagedResults/IAdapter.php +++ b/apps/user_ldap/lib/PagedResults/IAdapter.php @@ -37,32 +37,6 @@ interface IAdapter { */ public function setRequestParameters($link, int $pageSize, bool $isCritical): void; - /** - * The adapter is asked for an function that is being explicitly called to - * send the control parameters to LDAP. If not function has to be called, - * null shall be returned. - * - * It will used by the callee for diagnosis and error handling. - */ - public function getRequestCallFunc(): ?string; - - /** - * The adapter is asked to provide the arguments it would pass to the - * function returned by getRequestCallFunc(). If none shall be called, an - * empty array should be returned. - * - * It will used by the callee for diagnosis and error handling. - */ - public function getRequestCallArgs($link): array; - - /** - * The adapter is asked to do the necessary calls to LDAP, if - * getRequestCallFunc returned a function. If none, it will not be called - * so the return value is best set to false. Otherwise it shall respond - * whether setting the controls was successful. - */ - public function requestCall($link): bool; - /** * The adapter shall report which PHP function will be called to process * the paged results call diff --git a/apps/user_ldap/lib/PagedResults/Php73.php b/apps/user_ldap/lib/PagedResults/Php73.php index 1fc1fcdbab8..c9d12279937 100644 --- a/apps/user_ldap/lib/PagedResults/Php73.php +++ b/apps/user_ldap/lib/PagedResults/Php73.php @@ -87,10 +87,6 @@ class Php73 implements IAdapter { } } - public function getRequestCallFunc(): ?string { - return null; - } - public function setRequestParameters($link, int $pageSize, bool $isCritical): void { $linkId = $this->getLinkId($link); if (!isset($this->linkData[$linkId])) { @@ -105,16 +101,6 @@ class Php73 implements IAdapter { } } - public function getRequestCallArgs($link): array { - // no separate call - return []; - } - - public function requestCall($link): bool { - // no separate call - return false; - } - public function setSearchArgs( $link, string $baseDN,