Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

geoip.inc is breaking when geoip_* functions are already defined #9855

Closed
cerlestes opened this issue Feb 26, 2016 · 5 comments
Closed

geoip.inc is breaking when geoip_* functions are already defined #9855

cerlestes opened this issue Feb 26, 2016 · 5 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc. not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.

Comments

@cerlestes
Copy link

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
Copy link
Member

tsteur commented Feb 26, 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 tsteur added the Bug For errors / faults / flaws / inconsistencies etc. label Feb 26, 2016
@tsteur
Copy link
Member

tsteur commented Feb 26, 2016

refs #8689

@mattab
Copy link
Member

mattab commented Mar 31, 2016

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

@mattab mattab added this to the Mid term milestone Mar 31, 2016
@ghost
Copy link

ghost commented Jul 12, 2017

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

@sgiehl
Copy link
Member

sgiehl commented May 10, 2021

This shouldn't be an issue anymore as we switched to GeoIP2 and /libs/MaxMindGeoIP/geoip.inc isn't used any longer.

@sgiehl sgiehl closed this as completed May 10, 2021
@mattab mattab added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label May 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

No branches or pull requests

4 participants