From 81064b3d225250751ac91b4a5ad040bbb5fb7b77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 8 Sep 2022 16:29:23 +0200 Subject: [PATCH] Fix ldap_parse_result call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- apps/user_ldap/lib/LDAP.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/apps/user_ldap/lib/LDAP.php b/apps/user_ldap/lib/LDAP.php index 375a14675f4..8a840673a03 100644 --- a/apps/user_ldap/lib/LDAP.php +++ b/apps/user_ldap/lib/LDAP.php @@ -86,12 +86,21 @@ class LDAP implements ILDAPWrapper { $controls = []; $matchedDn = null; $referrals = []; - $success = $this->invokeLDAPMethod('parse_result', $link, $result, + + /** Cannot use invokeLDAPMethod because arguments are passed by reference */ + $this->preFunctionCall('ldap_parse_result', [$link, $result]); + $success = ldap_parse_result($link, $result, $errorCode, $matchedDn, $errorMessage, $referrals, $controls); + if ($this->isResultFalse($result)) { + $this->postFunctionCall(); + } + if ($this->dataCollector !== null) { + $this->dataCollector->stopLastLdapRequest(); + } $cookie = $controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'] ?? ''; @@ -281,11 +290,11 @@ class LDAP implements ILDAPWrapper { } /** + * @param array $arguments * @return mixed */ - protected function invokeLDAPMethod() { - $arguments = func_get_args(); - $func = 'ldap_' . array_shift($arguments); + protected function invokeLDAPMethod(string $func, ...$arguments) { + $func = 'ldap_' . $func; if (function_exists($func)) { $this->preFunctionCall($func, $arguments); $result = call_user_func_array($func, $arguments);