From 15b7103c53cfeed15956c99410565a9524a1ef69 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 25 Oct 2018 22:50:04 +0200 Subject: [PATCH] functions that were checked for are present since PHP 5.4, supported is >=/ * so the check from older days is really not necessary anymore * resolves #10923 Signed-off-by: Arthur Schiwon --- apps/user_ldap/lib/Access.php | 22 ++++++++----------- apps/user_ldap/lib/Configuration.php | 2 -- apps/user_ldap/lib/Connection.php | 9 -------- .../lib/Controller/ConfigAPIController.php | 1 - apps/user_ldap/lib/Group_LDAP.php | 2 +- apps/user_ldap/lib/ILDAPWrapper.php | 6 ----- apps/user_ldap/lib/LDAP.php | 10 --------- 7 files changed, 10 insertions(+), 42 deletions(-) diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php index a03b4a4cb9c6a..e05bc539a77e6 100644 --- a/apps/user_ldap/lib/Access.php +++ b/apps/user_ldap/lib/Access.php @@ -1855,15 +1855,15 @@ public function isDNPartOfBase($dn, $bases) { /** * resets a running Paged Search operation + * + * @throws ServerNotAvailableException */ private function abandonPagedSearch() { - if($this->connection->hasPagedResultSupport) { - $cr = $this->connection->getConnectionResource(); - $this->invokeLDAPMethod('controlPagedResult', $cr, 0, false, $this->lastCookie); - $this->getPagedSearchResultState(); - $this->lastCookie = ''; - $this->cookies = array(); - } + $cr = $this->connection->getConnectionResource(); + $this->invokeLDAPMethod('controlPagedResult', $cr, 0, false, $this->lastCookie); + $this->getPagedSearchResultState(); + $this->lastCookie = ''; + $this->cookies = []; } /** @@ -1902,10 +1902,6 @@ private function getPagedResultCookie($base, $filter, $limit, $offset) { * @return bool */ public function hasMoreResults() { - if(!$this->connection->hasPagedResultSupport) { - return false; - } - if(empty($this->lastCookie) && $this->lastCookie !== '0') { // as in RFC 2696, when all results are returned, the cookie will // be empty. @@ -1954,7 +1950,7 @@ public function getPagedSearchResultState() { */ private function initPagedSearch($filter, $bases, $attr, $limit, $offset) { $pagedSearchOK = false; - if($this->connection->hasPagedResultSupport && ($limit !== 0)) { + if ($limit !== 0) { $offset = (int)$offset; //can be null \OCP\Util::writeLog('user_ldap', 'initializing paged search for Filter '.$filter.' base '.print_r($bases, true) @@ -2000,7 +1996,7 @@ private function initPagedSearch($filter, $bases, $attr, $limit, $offset) { * So we added "&& !empty($this->lastCookie)" to this test to ignore pagination * if we don't have a previous paged search. */ - } else if($this->connection->hasPagedResultSupport && $limit === 0 && !empty($this->lastCookie)) { + } else if ($limit === 0 && !empty($this->lastCookie)) { // a search without limit was requested. However, if we do use // Paged Search once, we always must do it. This requires us to // initialize it with the configured page size. diff --git a/apps/user_ldap/lib/Configuration.php b/apps/user_ldap/lib/Configuration.php index 25d64859596b9..c912d30b49b59 100644 --- a/apps/user_ldap/lib/Configuration.php +++ b/apps/user_ldap/lib/Configuration.php @@ -95,7 +95,6 @@ class Configuration { 'ldapAttributesForGroupSearch' => null, 'ldapExperiencedAdmin' => false, 'homeFolderNamingRule' => null, - 'hasPagedResultSupport' => false, 'hasMemberOfFilterSupport' => false, 'useMemberOfToDetectMembership' => true, 'ldapExpertUsernameAttr' => null, @@ -278,7 +277,6 @@ public function saveConfiguration() { break; //following options are not stored but detected, skip them case 'ldapIgnoreNamingRules': - case 'hasPagedResultSupport': case 'ldapUuidUserAttribute': case 'ldapUuidGroupAttribute': continue 2; diff --git a/apps/user_ldap/lib/Connection.php b/apps/user_ldap/lib/Connection.php index c912d9f89f804..7becf311a2254 100644 --- a/apps/user_ldap/lib/Connection.php +++ b/apps/user_ldap/lib/Connection.php @@ -50,7 +50,6 @@ * @property string ldapUserDisplayName2 * @property string ldapUserAvatarRule * @property boolean turnOnPasswordChange - * @property boolean hasPagedResultSupport * @property string[] ldapBaseUsers * @property int|null ldapPagingSize holds an integer * @property bool|mixed|void ldapGroupMemberAssocAttr @@ -67,7 +66,6 @@ class Connection extends LDAPUtility { private $configPrefix; private $configID; private $configured = false; - private $hasPagedResultSupport = true; //whether connection should be kept on __destruct private $dontDestruct = false; @@ -112,9 +110,6 @@ public function __construct(ILDAPWrapper $ldap, $configPrefix = '', $configID = $helper = new Helper(\OC::$server->getConfig()); $this->doNotValidate = !in_array($this->configPrefix, $helper->getServerConfigurationPrefixes()); - $this->hasPagedResultSupport = - (int)$this->configuration->ldapPagingSize !== 0 - || $this->ldap->hasPagedResultSupport(); } public function __destruct() { @@ -146,10 +141,6 @@ public function __get($name) { $this->readConfiguration(); } - if($name === 'hasPagedResultSupport') { - return $this->hasPagedResultSupport; - } - return $this->configuration->$name; } diff --git a/apps/user_ldap/lib/Controller/ConfigAPIController.php b/apps/user_ldap/lib/Controller/ConfigAPIController.php index e000bd4e709ae..a745e4ce060a3 100644 --- a/apps/user_ldap/lib/Controller/ConfigAPIController.php +++ b/apps/user_ldap/lib/Controller/ConfigAPIController.php @@ -260,7 +260,6 @@ public function modify($configID, $configData) { * * 0 * - * * * 1 * uid diff --git a/apps/user_ldap/lib/Group_LDAP.php b/apps/user_ldap/lib/Group_LDAP.php index 57f5faebd2ca6..2240c2ad229ba 100644 --- a/apps/user_ldap/lib/Group_LDAP.php +++ b/apps/user_ldap/lib/Group_LDAP.php @@ -1007,7 +1007,7 @@ public function getGroups($search = '', $limit = -1, $offset = 0) { } $search = $this->access->escapeFilterPart($search, true); $pagingSize = (int)$this->access->connection->ldapPagingSize; - if (!$this->access->connection->hasPagedResultSupport || $pagingSize <= 0) { + if ($pagingSize <= 0) { return $this->getGroupsChunk($search, $limit, $offset); } $maxGroups = 100000; // limit max results (just for safety reasons) diff --git a/apps/user_ldap/lib/ILDAPWrapper.php b/apps/user_ldap/lib/ILDAPWrapper.php index 52919c48e5fa8..f43b59dd107dc 100644 --- a/apps/user_ldap/lib/ILDAPWrapper.php +++ b/apps/user_ldap/lib/ILDAPWrapper.php @@ -206,12 +206,6 @@ public function unbind($link); * */ public function areLDAPFunctionsAvailable(); - /** - * Checks whether PHP supports LDAP Paged Results - * @return bool true if it the case, false otherwise - * */ - public function hasPagedResultSupport(); - /** * Checks whether the submitted parameter is a resource * @param resource $resource the resource variable to check diff --git a/apps/user_ldap/lib/LDAP.php b/apps/user_ldap/lib/LDAP.php index bdc2f204225f3..2411b8d3438e3 100644 --- a/apps/user_ldap/lib/LDAP.php +++ b/apps/user_ldap/lib/LDAP.php @@ -238,16 +238,6 @@ public function areLDAPFunctionsAvailable() { return function_exists('ldap_connect'); } - /** - * Checks whether PHP supports LDAP Paged Results - * @return boolean if it the case, false otherwise - * */ - public function hasPagedResultSupport() { - $hasSupport = function_exists('ldap_control_paged_result') - && function_exists('ldap_control_paged_result_response'); - return $hasSupport; - } - /** * Checks whether the submitted parameter is a resource * @param Resource $resource the resource variable to check