Title: Incompatibility   fix
Last modified: August 21, 2016

---

# Incompatibility fix

 *  Resolved [Diego](https://wordpress.org/support/users/daigo75/)
 * (@daigo75)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/incompatibility-fix/)
 * I spotted an issue in the plugin, which makes it incompatible with any plugin
   using the same GeoIP library (e.g. [Geo Redirect](https://wordpress.org/plugins/geographical-redirect/)).
   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](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://wordpress.org/plugins/iq-block-country/](https://wordpress.org/plugins/iq-block-country/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Pascal](https://wordpress.org/support/users/iqpascal/)
 * (@iqpascal)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/incompatibility-fix/#post-5151432)
 * I think I did pretty much the same as you did except for checking if the DEFINE
   statements already exist.
 * But I am already checking if the GeoIP class exists and if not it includes geoip.
   inc, and also check each function in the geoip.inc file if it already exists 
   or not.
 * But my geoip.inc file is newer than the version Geo Redirect is using.
 * Are you sure that your situation crashes by iQ Block Country? As on a glance 
   we appear to use the same geoip.inc file (or pretty much).
 *  Thread Starter [Diego](https://wordpress.org/support/users/daigo75/)
 * (@daigo75)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/incompatibility-fix/#post-5151436)
 * One of our clients had the plugins I mentioned installed and reported a crash
   when both of them were enabled. If any of the two is disabled, the website works
   fine. That’s what led me to think that the iQ Block Country plugin has something
   to do with it (my findings were based on a quick review of the code).
 * If the plugin already includes the necessary checks, then it may be possible 
   that the customer is using an older version.
 * Just a suggestion: in `geoip.inc`, you should also check for the definitions.
   Redeclaring a definition can cause a fatal error, like redeclaring a function.
 *  Plugin Author [Pascal](https://wordpress.org/support/users/iqpascal/)
 * (@iqpascal)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/incompatibility-fix/#post-5151496)
 * To save me some work in also checking the defintions I have added your version
   of the geoip.inc to a beta version and it works fine so next production release
   I will most likely use your version.
 *  Thread Starter [Diego](https://wordpress.org/support/users/daigo75/)
 * (@daigo75)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/incompatibility-fix/#post-5151497)
 * Perfect, thanks for your help. 🙂

Viewing 4 replies - 1 through 4 (of 4 total)

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

 * ![](https://ps.w.org/iq-block-country/assets/icon-128x128.png?rev=3136019)
 * [iQ Block Country](https://wordpress.org/plugins/iq-block-country/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/iq-block-country/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/iq-block-country/)
 * [Active Topics](https://wordpress.org/support/plugin/iq-block-country/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/iq-block-country/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/iq-block-country/reviews/)

## Tags

 * [conflict](https://wordpress.org/support/topic-tag/conflict/)

 * 4 replies
 * 2 participants
 * Last reply from: [Diego](https://wordpress.org/support/users/daigo75/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/incompatibility-fix/#post-5151497)
 * Status: resolved