@cerlestes opened this issue on February 26th 2016

### Abstract

/libs/MaxMindGeoIP/geoip.inc isn't checking whether all functions that it implements in the geoip_* namespace already exist. This can lead to fatal errors in Piwik when a non-default version of geoip.so is installed on the server. ### Solution

Every geoip_* function defined in this file should be surrounded by a check for existence, like some of them already have them.

if (!function_exists('geoip_xxx')) {
...
}

### Example

We've recently upgraded our production environment to PHP7, using Ondřej Surý's excellent PPA for PHP7 in Ubuntu. But as the official geoip extension hasn't been ported to PHP7 yet, we had to compile some fork that has this support enabled. The best choice seemed to be @Zakays fork (https://github.com/Zakay/geoip) and it worked fine for our needs. This extension also implements some functions in the geoip_* namespace that aren't available in the default PHP5 extension, but are defined in the aforementioned geoip.inc file, which leads to an error like:

PHP Fatal error:  Cannot redeclare geoip_country_code_by_addr() in /var/www/piwik/libs/MaxMindGeoIP/geoip.inc
@tsteur commented on February 26th 2016

Good point, I think it's already done for many functions but possibly not for all that are needed. Can you maybe add a if (!function_exists('geoip_country_code_by_addr')) { ... } around the function and see if more functions need such a check? A pull request could be really helpful.

@tsteur commented on February 26th 2016

refs #8689

@mattab commented on March 31st 2016

Hi @cerlestes - it would be awesome if you can create a pull request to solve this issue :+1:

@Josua2012 commented on July 12th 2017

We are in July 2017. When will this problem be solved? :(

Powered by GitHub Issue Mirror