Skip to content

Commit

Permalink
Merge pull request #20274 from nextcloud/fix/19127/ldap-silence-depre…
Browse files Browse the repository at this point in the history
…cation-stable18

silence LDAP deprecation logs in NC 18
  • Loading branch information
rullzer authored Apr 2, 2020
2 parents ae08c56 + 9359d8b commit 3c7e708
Showing 1 changed file with 33 additions and 8 deletions.
41 changes: 33 additions & 8 deletions apps/user_ldap/lib/LDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,24 @@ public function connect($host, $port) {
* @return bool|LDAP
*/
public function controlPagedResultResponse($link, $result, &$cookie) {
$this->preFunctionCall('ldap_control_paged_result_response',
array($link, $result, $cookie));
$result = ldap_control_paged_result_response($link, $result, $cookie);
$this->postFunctionCall();

return $result;
$oldHandler = set_error_handler(function($no, $message, $file, $line) use (&$oldHandler) {
if(strpos($message, 'ldap_control_paged_result_response() is deprecated') !== false) {
return true;
}
$oldHandler($no, $message, $file, $line);
return true;
});
try {
$this->preFunctionCall('ldap_control_paged_result_response',
array($link, $result, $cookie));
$result = ldap_control_paged_result_response($link, $result, $cookie);
$this->postFunctionCall();
restore_error_handler();
return $result;
} catch (\Exception $e) {
restore_error_handler();
throw $e;
}
}

/**
Expand All @@ -86,8 +98,21 @@ public function controlPagedResultResponse($link, $result, &$cookie) {
* @return mixed|true
*/
public function controlPagedResult($link, $pageSize, $isCritical, $cookie) {
return $this->invokeLDAPMethod('control_paged_result', $link, $pageSize,
$isCritical, $cookie);
$oldHandler = set_error_handler(function($no, $message, $file, $line) use (&$oldHandler) {
if(strpos($message, 'Function ldap_control_paged_result() is deprecated') !== false) {
return true;
}
$oldHandler($no, $message, $file, $line);
return true;
});
try {
$result = $this->invokeLDAPMethod('control_paged_result', $link, $pageSize, $isCritical, $cookie);
restore_error_handler();
return $result;
} catch (\Exception $e) {
restore_error_handler();
throw $e;
}
}

/**
Expand Down

0 comments on commit 3c7e708

Please sign in to comment.