Skip to content

Commit

Permalink
Merge pull request #371 from DirectoryTree/patch-php-8.1-support
Browse files Browse the repository at this point in the history
Patch php 8.1 support
  • Loading branch information
stevebauman committed Dec 13, 2021
2 parents dffdd1c + 61cd244 commit b6e1d6f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Ldap.php
Expand Up @@ -2,6 +2,9 @@

namespace LdapRecord;

use LDAP\Connection as RawLdapConnection;

/** @psalm-suppress UndefinedClass */
class Ldap implements LdapInterface
{
use HandlesConnection, DetectsErrors;
Expand Down Expand Up @@ -202,7 +205,9 @@ public function connect($hosts = [], $port = 389)
*/
public function close()
{
$result = is_resource($this->connection) ? @ldap_close($this->connection) : false;
$result = (is_resource($this->connection) || $this->connection instanceof RawLdapConnection)
? @ldap_close($this->connection)
: false;

$this->connection = null;
$this->bound = false;
Expand Down
4 changes: 3 additions & 1 deletion src/Query/Builder.php
Expand Up @@ -6,6 +6,7 @@
use Closure;
use DateTimeInterface;
use InvalidArgumentException;
use LDAP\Result;
use LdapRecord\Connection;
use LdapRecord\Container;
use LdapRecord\EscapesValues;
Expand All @@ -19,6 +20,7 @@
use LdapRecord\Support\Arr;
use LdapRecord\Utilities;

/** @psalm-suppress UndefinedClass */
class Builder
{
use EscapesValues;
Expand Down Expand Up @@ -673,7 +675,7 @@ public function parse($resource)
$entries = $ldap->getEntries($resource);

// Free up memory.
if (is_resource($resource)) {
if (is_resource($resource) || $resource instanceof Result) {
$ldap->freeResult($resource);
}

Expand Down

0 comments on commit b6e1d6f

Please sign in to comment.