Fixed TypeError: array_merge(): Argument #1 must be of type array, bool given src/XF/Http/Reader.php:118

Kirby

Well-known member
Affected version
2.2.10 PL 1
PHP:
$ips = array_merge(
    $data['ipv4s'],
    array_map(
        function ($ipv6) { return '[' . $ipv6 . ']'; },
        $data['ipv6s']
    )
);

So $data['ipv4s'] is a bool here - this seems to happen if the name cannot be resolved using IPv4:

PHP:
    public function isRequestableUntrustedUrlExtended($url, &$data = [], &$error = null)
    {
        [...]
   
        $ips = @gethostbynamel($parts['host']);
        if ($ips)

        [...]

        $data = [
            'scheme' => $parts['scheme'],
            'host' => $parts['host'],
            'port' => $parts['port'] ?? null,
            'ipv4s' => $ips,
            'ipv6s' => array_column($ipv6s, 'ipv6')
        ];
        return true;

So in case an IPv6 resolution is successful (but IPv4 isn't) the function returns true, but ipv4s remains false (should be an empty array instead).

Btw: Why doesn't this entirely new method have a return type?
 
Last edited:
Yep this also has been triggered for some of our AMPXF users and we'll probably need to add some temporary error suppression for this version..
 
Back
Top Bottom