Skip to content

Commit 5b1740a

Browse files
committed
Fix ldap_parse_result call
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
1 parent c2704ab commit 5b1740a

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

apps/user_ldap/lib/LDAP.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,21 @@ public function controlPagedResultResponse($link, $result, &$cookie): bool {
8686
$controls = [];
8787
$matchedDn = null;
8888
$referrals = [];
89-
$success = $this->invokeLDAPMethod('parse_result', $link, $result,
89+
90+
/** Cannot use invokeLDAPMethod because arguments are passed by reference */
91+
$this->preFunctionCall('ldap_parse_result', [$link, $result]);
92+
$success = ldap_parse_result($link, $result,
9093
$errorCode,
9194
$matchedDn,
9295
$errorMessage,
9396
$referrals,
9497
$controls);
98+
if ($this->isResultFalse($result)) {
99+
$this->postFunctionCall();
100+
}
101+
if ($this->dataCollector !== null) {
102+
$this->dataCollector->stopLastLdapRequest();
103+
}
95104

96105
$cookie = $controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'] ?? '';
97106

@@ -281,11 +290,11 @@ protected function isResultFalse($result) {
281290
}
282291

283292
/**
293+
* @param array $arguments
284294
* @return mixed
285295
*/
286-
protected function invokeLDAPMethod() {
287-
$arguments = func_get_args();
288-
$func = 'ldap_' . array_shift($arguments);
296+
protected function invokeLDAPMethod(string $func, ...$arguments) {
297+
$func = 'ldap_' . $func;
289298
if (function_exists($func)) {
290299
$this->preFunctionCall($func, $arguments);
291300
$result = call_user_func_array($func, $arguments);

0 commit comments

Comments
 (0)