php-epp-client icon indicating copy to clipboard operation
php-epp-client copied to clipboard

Fatal Error in eppInfoHostResponse.php

Open DECEiFER opened this issue 3 years ago • 0 comments
trafficstars

Hi,

Just letting you know that PHP 8 is throwing an E_ERROR in eppInfoHostResponse.php when array_keys() is run in get_host() due to the return value from getHostAddresses() being null. In PHP <=7 it was just an E_WARNING.

public function getHost() {
        $hostname = $this->getHostName();
        $address = $this->getHostAddresses();
        $address = array_keys($address);
        $host = new eppHost($hostname, $address);
        return $host;
    }

public function getHostAddresses() {
        $ip = null;
        $xpath = $this->xPath();
        $result = $xpath->query('/epp:epp/epp:response/epp:resData/host:infData/host:addr');
        foreach ($result as $address) {
            /* @var $address \DOMElement */
            $ip[$address->nodeValue] = $address->getAttribute('ip');
        }
        return $ip;
    }

I'm modifying it to:

public function getHostAddresses() {
        $ip = array();
        $xpath = $this->xPath();
        $result = $xpath->query('/epp:epp/epp:response/epp:resData/host:infData/host:addr');
        foreach ($result as $address) {
            /* @var $address \DOMElement */
            $ip[$address->nodeValue] = $address->getAttribute('ip');
        }
        return $ip;
    }

Thanks for the excellent work!

DECEiFER avatar Sep 27 '22 16:09 DECEiFER