Conflicting autoload
-
I am a WP developer.
I installed this plugin for a client, and discovered that it was working on the backend, but not the frontend. While troubleshooting, I discovered that I was getting Country: “Unknown” for requests that were not under
/wp-admin/. Digging deeper, I found that all frontend requests (all requests for anything not underwp-admin/) were getting hung up inblockcountry-checks.phpon line 19:class_exists('GeoIp2\\Database\\Reader')The root cause is that, while on the frontend, this client’s theme has its own vendor/autoload, so nothing that’s supposed to work as a result of
require_once( 'vendor/autoload.php' );from your plugin will function. My client is probably not an isolated case – your autoload isn’t best-practices.Here is the fix: Change line 291 in iq-block-country.php to this:
require_once( dirname( __FILE__ ) . '/vendor/autoload.php');Failure to do that may do one of two things to anyone else that uses an autoload: 1) Skip your autoload and break your plugin, or 2) Skip somebody else’s autoload and break their theme/plugin. This simple change will fix it for everyone with no downside – it’s the correct way to autoload.
Please fix.
The page I need help with: [log in to see the link]
The topic ‘Conflicting autoload’ is closed to new replies.