pear / Net_LDAP2

Object oriented interface for searching and manipulating LDAP-entries
http://pear.php.net/package/Net_LDAP2
GNU Lesser General Public License v3.0
10 stars 6 forks source link

since PHP 8.0 Fatal error is thrown by _PEAR_call_destructors() #15

Open gregoryR opened 1 month ago

gregoryR commented 1 month ago

Hi

Using Net_LDAP2 2.3.0 a Fatal error is thrown by the destructor on PHP 8.0+

Minimal code

<?php
require "/app/vendor/autoload.php"; // Using composer to call pear/net_ldap2 2.3.0

echo "PHP version : " . phpversion() . "\n";

$confldap = array(
    'binddn'    => getenv("LDAPDN"),
    'bindpw'    => getenv("LDAPPASSWORD"),
    'basedn'    => getenv("LDAPBASE"),
    'host'      => getenv("LDAPSERVER"),
);
$ldap = Net_LDAP2::connect($confldap);
if (PEAR::isError($ldap)) {
    echo "Net_LDAP2::connect() error : " . $ldap->getMessage() . "\n";
} else {
    echo "Net_LDAP2::connect() OK\n";
}
// ldap disconnet
if (!PEAR::isError($ldap)) {
    $ldap->done();
    echo "Net_LDAP2->done() OK\n";
}

Using docker image php:7.4-cli everything seems OK, in output

PHP version : 7.4.33
Net_LDAP2::connect() OK
Net_LDAP2->done() OK

With php:8.0-cli

PHP version : 8.0.30
Net_LDAP2::connect() OK
Net_LDAP2->done() OK

Fatal error: Uncaught TypeError: ldap_close(): supplied resource is not a valid ldap link resource in /app/vendor/pear/net_ldap2/Net/LDAP2.php:701
Stack trace:
#0 /app/vendor/pear/net_ldap2/Net/LDAP2.php(701): ldap_close(Resource id #21)
#1 /app/vendor/pear/pear-core-minimal/src/PEAR.php(812): Net_LDAP2->_Net_LDAP2()
#2 [internal function]: _PEAR_call_destructors()
#3 {main}
  thrown in /app/vendor/pear/net_ldap2/Net/LDAP2.php on line 701

With php:8.1-cli same error. There are Deprecated warnings too, but seems unrelated

PHP version : 8.1.30

Deprecated: Return type of Net_LDAP2_Search::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/pear/net_ldap2/Net/LDAP2/Search.php on line 565

Deprecated: Return type of Net_LDAP2_Search::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/pear/net_ldap2/Net/LDAP2/Search.php on line 596

Deprecated: Return type of Net_LDAP2_Search::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/pear/net_ldap2/Net/LDAP2/Search.php on line 581

Deprecated: Return type of Net_LDAP2_Search::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/pear/net_ldap2/Net/LDAP2/Search.php on line 619

Deprecated: Return type of Net_LDAP2_Search::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/pear/net_ldap2/Net/LDAP2/Search.php on line 632
Net_LDAP2::connect() OK
Net_LDAP2->done() OK

Fatal error: Uncaught Error: LDAP connection has already been closed in /app/vendor/pear/net_ldap2/Net/LDAP2.php:701
Stack trace:
#0 /app/vendor/pear/net_ldap2/Net/LDAP2.php(701): ldap_close(Object(LDAP\Connection))
#1 /app/vendor/pear/pear-core-minimal/src/PEAR.php(812): Net_LDAP2->_Net_LDAP2()
#2 [internal function]: _PEAR_call_destructors()
#3 {main}
  thrown in /app/vendor/pear/net_ldap2/Net/LDAP2.php on line 701