From 044551085a37ebb8f394f3e3a7ba9a7cde377ffb Mon Sep 17 00:00:00 2001 From: bmortier <benoit.mortier@fusiondirectory.org> Date: Tue, 29 Jun 2021 22:00:03 +0000 Subject: [PATCH] Revert "Merge branch '6175-compatibility-with-php-8-1' into '1.4-dev'" This reverts merge request !914 --- include/class_config.inc | 2 +- include/class_ldap.inc | 21 +++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/include/class_config.inc b/include/class_config.inc index 2b1bedbc6..9318e13cb 100644 --- a/include/class_config.inc +++ b/include/class_config.inc @@ -308,7 +308,7 @@ class config { global $ui; - if (($this->ldapLink === NULL) || ($this->ldapLink->cid === FALSE)) { + if ($this->ldapLink === NULL || !is_resource($this->ldapLink->cid)) { /* Build new connection */ $this->ldapLink = LDAP::init($this->current['SERVER'], $this->current['BASE'], $this->current['ADMINDN'], $this->get_credentials($this->current['ADMINPASSWORD'])); diff --git a/include/class_ldap.inc b/include/class_ldap.inc index e44eab6e4..df420ee05 100644 --- a/include/class_ldap.inc +++ b/include/class_ldap.inc @@ -37,12 +37,8 @@ class LDAP var $reconnect = FALSE; var $tls = FALSE; - /** - * Connection identifier - * - * @var resource|object|false - */ - var $cid = FALSE; + /* connection identifier */ + var $cid; var $hasres = []; var $sr = []; @@ -298,7 +294,7 @@ class LDAP function unbind () { @ldap_unbind($this->cid); - $this->cid = FALSE; + $this->cid = NULL; logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, '', 'unbind'); } @@ -773,8 +769,9 @@ class LDAP $r = ldap_rename($this->cid, $source, $dest_rdn, $parent, TRUE); $this->error = ldap_error($this->cid); - /* Check if destination dn exists, if not the server may not support this operation */ - $r &= $this->dn_exists($dest); + /* Check if destination dn exists, if not the + server may not support this operation */ + $r &= is_resource($this->dn_exists($dest)); logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'rename("'.$source.'","'.$dest.'")'); return $r; } else { @@ -1205,7 +1202,7 @@ class LDAP // Try to open the process $process = proc_open($cmd, $descriptorspec, $pipes); - if ($process !== FALSE) { + if (is_resource($process)) { // Write the password to stdin fclose($pipes[0]); @@ -1224,10 +1221,10 @@ class LDAP return $res; } - function dn_exists ($dn): bool + function dn_exists ($dn) { logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, '', 'dn_exists('.$dn.')'); - return (@ldap_read($this->cid, $dn, '(objectClass=*)', ['objectClass']) !== FALSE); + return @ldap_read($this->cid, $dn, "(objectClass=*)", ["objectClass"]); } function parseLdif (string $str_attr): array -- GitLab