• I spotted an issue in the plugin, which makes it incompatible with any plugin using the same GeoIP library (e.g. iQ Block Country). The issue is that the plugin loads the geoip.inc file unconditionally, without checking if such library has already been loaded, and will crash if another plugin has loaded the same library earlier.

    We could reproduce this issue consistently while using the plugin with our Currency Switcher for WooCommerce, which uses the same library, but checks if it has been loaded first. When both plugins are installed, two scenarios can occur.

    Scenario 1
    1. Block Country plugin loads first
    2. Block Country plugin loads geoip.inc.
    3. The Currency Switcher loads.
    4. The Currency Switcher checks if geoip.inc has been loaded, and skips it.
    5. Site works normally.

    Scenario 2
    1. The Currency Switcher loads first.
    2. The Currency Switcher checks if geoip.inc has been loaded. This is not the case, to it loads the library.
    3. Block Country plugin loads
    4. Block Country plugin **loads geoip.inc without checking, and crashes**. This is the error to correct.

    Solution
    Since there is no way to guarantee in which order plugins will be processed by WordPress, your plugin should check if the MaxMind library has been loaded before trying to load it again.

    Due to the procedural design of such an old library, such check is not as straightforward as it should be, but you can use the modified geoip.inc that we added to our products, which already includes all necessary conditions. You can find it in our GitHub repository: https://github.com/daigo75/geoip-api-php. The library is an almost exact copy of the original one, with several conditions added to prevent duplicate loading and related crashes.

    https://ww.wp.xz.cn/plugins/geographical-redirect/

The topic ‘Incompatibility fix’ is closed to new replies.