Closed EusebiuOprinoiu closed 3 years ago
@EusebiuOprinoiu Thanks for letting me know, strange one. Zero Spam doesn't use that library directly, instead is a dependency for the IPinfo library. As such, you'll need to contact IPinfo about a resolution. Once they get their library updated, I can update it on ZS which should hopefully fix the issue.
Understand that's a major pain with it being a fatal error. I will look into only including that library if IPinfo is enabled. That way you can disable it and avoid that error until there's a resolution from their side. I try to get that up in the next release.
@EusebiuOprinoiu Pushed an update to the master branch to only load the library if ipinfo is enabled. Can you download it (https://github.com/bmarshall511/wordpress-zero-spam/archive/refs/heads/master.zip) to see if it fixes your issue?
Since I am not using IPinfo, the problem goes away, but your solution is not really a fix. It's just a way to limit the number of websites impacted by this issue.
There is nothing wrong with the IPinfo library or the fact that they use GuzzleHttp. The underlying problem is that WordPress doesn’t have a way of dealing with third-party code in plugins or themes and, by default, does not play well with Composer. WordPress has a very specific order for loading plugins, and you never know if your plugin loads after another plugin that uses a different, incompatible version of the same dependency.
Delicious Brains uses this Impostor Plugin to namespace all their Composer dependencies. I haven't personally used this before, but as far as I can tell, all you have to do is add it as an extra dependency to Composer and define a unique namespace for your plugin in composer.json
.
@EusebiuOprinoiu Right, not a fix, temporary solution as I mentioned. Wanted to get something up quick for you to get rid of the fatal error.
Again, zero spam doesn't load any libraries except for IPinfo. The fact you're getting that error is due to how IPinfo loads its dependencies, not zero spam since it has no required dependencies.
I'll look into that Impostor Plugin for loading the IPinfo library, hopefully, that'll resolve the core issue.
Thank you. I appreciate it! This temporary solution is good enough for me. All I wanted to say is that a proper fix is needed in the long run because it will cause issues with almost every plugin that uses this library for remote connections. And there are a lot of them. (some of them essential, like backup or SMTP plugins) I have seen this issue 6 or 7 times this year alone and every time it was fixed by namespacing the library.
Hello, Ben! The latest version of WordPress Zero Spam introduced a conflict between WordPress Zero Spam and other plugins that use GuzzleHttp.
PHP Fatal error: Uncaught Error: Call to undefined method GuzzleHttp\Utils::chooseHandler() in /wp-content/plugins/zero-spam/vendor/guzzlehttp/guzzle/src/functions.php:61
Pixel Caffeine had this exact problem when they updated the library a while back. They fixed the problem by scoping the library within a different namespace. WP Offload Media from Delicious Brains also uses GuzzleHttp and they also namespace the library bundled within their plugin. If it helps, they briefly mention how they do it in one of their blog posts: https://deliciousbrains.com/wordpress-http-api-requests
In my case, the conflict appears between WordPress Zero Spam and BackWPup when using Amazon S3 as backup destination. The fatal error appears both on the settings page for the Amazon S3 connection and while running a backup, which makes all backups fail.