geocoder-php / Geocoder

The most featured Geocoder library written in PHP.
https://geocoder-php.org
MIT License
3.94k stars 515 forks source link

[MaxMindBinary] Fatal error when trying to build an `AddressCollection` - Tag 4.0 #946

Closed xserrat closed 5 years ago

xserrat commented 5 years ago

Hi,

I've found a bug when the given IP address returns a GeoIpRecord but with the city field has a NULL value.

The error is: Fatal error: Uncaught TypeError: utf8_encode() expects parameter 1 to be string, null given in /var/www/sifo/vendor/geocoder-php/maxmind-binary-provider/MaxMindBinary.php on line 109.

(https://github.com/geocoder-php/Geocoder/blob/master/src/Provider/MaxMindBinary/MaxMindBinary.php#L109)

So, before applying the utf8_encode to the city or country_name we should check if the value is null.