Skip to content

Commit

Permalink
fix(ldap): pagination for PHP 7.4 & 8.0
Browse files Browse the repository at this point in the history
After PR symfony#38392 there is a little issue in the Symfony code base that
occurs only for PHP 7.4 and PHP 8.0.

This is related to issue symfony#38874
  • Loading branch information
Nek- committed Oct 29, 2020
1 parent 2fb61a4 commit 02f4ffd
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ public function getResources(): array
private function resetPagination()
{
$con = $this->connection->getResource();
$this->controlPagedResultResponse($con, 0, '');
$this->serverctrls = [];
$this->controlPagedResultResponse($con, null, '');

// This is a workaround for a bit of a bug in the above invocation
// of ldap_control_paged_result. Instead of indicating to extldap that
Expand Down Expand Up @@ -226,16 +225,23 @@ private function controlPagedResult($con, int $pageSize, string $cookie): bool
/**
* Retrieve LDAP pagination cookie.
*
* @param resource $con
* @param resource $result
* @param resource $con
* @param resource|null $result
*/
private function controlPagedResultResponse($con, $result, string $cookie = ''): string
{
$this->serverctrls = [];

if (\PHP_VERSION_ID < 70300) {
ldap_control_paged_result_response($con, $result, $cookie);

return $cookie;
}

if (null === $result) {
return '';
}

ldap_parse_result($con, $result, $errcode, $matcheddn, $errmsg, $referrals, $controls);

return $controls[\LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'] ?? '';
Expand Down

0 comments on commit 02f4ffd

Please sign in to comment.