mikepultz / netdns2

Native PHP DNS Resolver and Updater
https://netdns2.com/
Other
119 stars 64 forks source link

php 8.1 compatibility #127

Closed Pascal76 closed 2 years ago

Pascal76 commented 2 years ago

Hello,

Would you have time to make the code compatible with php 8.1 ? ex: Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /apache_sites/jbm/lib_8.1/vendor/pear/net_dns2/Net/DNS2/Socket.php on line 132

offsky commented 2 years ago

Im just starting to upgrade to PHP 8.1 and found this warning too. The solution is pretty easy. On line 132 of Socket.php change to if (!empty($this->local_host) && strlen($this->local_host) > 0) {

Jellyfrog commented 2 years ago

Stupid quickfix:

$this->resolver = new \Net_DNS2_Resolver();
// Workaround for strlen() null
// https://github.com/mikepultz/netdns2/blob/master/Net/DNS2/Socket.php#L132
$this->resolver->local_host = "0";
Blackbam commented 2 years ago

Recognized the same. Merging this would be great.

Pascal76 commented 2 years ago

php 7.4 EOL is coming very soon (in less than 20 days). Lot of people will move to php 8.1 It would be great to finalize the compatibility.

Blackbam commented 2 years ago

@mikepultz Can you please merge that (see discussion)? Otherwise some people might have to do a fork, although the quickfix works it is not the best solution.

Pascal76 commented 2 years ago

thank you for the new build !!!

Pascal76 commented 2 years ago

=)