dotmailer / dotdigital-for-wordpress

The official Dotdigital for WordPress plugin
https://wordpress.org/plugins/dotmailer-sign-up-widget/
MIT License
1 stars 5 forks source link

`PHP Fatal error: Uncaught Http\Discovery\Exception\DiscoveryFailedException` #8

Closed codepuncher closed 1 year ago

codepuncher commented 1 year ago

Upgrading to https://github.com/dotmailer/dotdigital-signup-form/releases/tag/v6.0.3 causes fatal errors on sites using the plugin.

2023/06/21 07:26:21 [error] 9019#9019: *3449761 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Http\Discovery\Exception\DiscoveryFailedException: Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#common-errors
- No valid candidate found using strategy "Http\Discovery\Strategy\CommonClassesStrategy". We tested the following candidates: Nyholm\Psr7\Factory\HttplugFactory, Http\Message\MessageFactory\GuzzleMessageFactory, Http\Message\MessageFactory\DiactorosMessageFactory, Http\Message\MessageFactory\SlimMessageFactory.
- No valid candidate found using strategy "Http\Discovery\Strategy\CommonPsr17ClassesStrategy". We tested the following candidates: .
in /path/to/plugins/dotmailer-sign-up-widget/vendor/php-http/discovery/src/Exception/DiscoveryFailedException.php:41
Stack trace:
#0 /path/to/plugins/dotmailer-sign-up-widget/vendor/php-http/discovery/src/ClassDiscover" while reading response header from upstream, client: 82.153.21.255, server: www.example.co.uk, request: "POST /support-us/make-a-donation/single-donation/?amount=25.00 HTTP/2.0", upstream: "fastcgi://unix:/var/run/php8.1-fpm-example.sock:", host: "www.example.co.uk:23987", referrer: "https://www.example.co.uk/support-us/make-a-donation/single-donation/?amount=25.00"

I am guessing that perhaps a package is missing from your vendor directory in the published ZIP for the release?

Let me know if I can assist with tests.

Thanks

sta1r commented 1 year ago

@codepuncher sorry about this. Would have come back to you sooner also, but this issue wasn't forwarded.

OK - I can't actually reproduce this using the tagged 6.0.3 files. Does it happen on widget submit?

Does it still happen for you if set this in composer.json:

"config": {
        "allow-plugins": {
            "dealerdirect/phpcodesniffer-composer-installer": true,
            "php-http/discovery": false
        }
    }

The vendor folder as tagged should have everything required: http://plugins.svn.wordpress.org/dotmailer-sign-up-widget/tags/6.0.3/vendor/ but perhaps the discovery package is looking for other options because we've told it to do so.

codepuncher commented 1 year ago

No worries.

It is happening on submit of a form from a different plugin (Gravity Forms).

I have changed php-http/discovery to false but it has made no difference.

I should add that the WordPress site is Composer managed which may be related to the issue? Seems that we have Composer packages that use similar packages in our project root vendor.

sta1r commented 1 year ago

How does it work then, you add our plugin from the WordPress repository then run composer install? Did you re-run composer install after setting "php-http/discovery": false?

I'd appreciate any help you can give us here, we don't currently have a composer-installed local env to replicate on. Here's the diff between 6.0.3 and 6.0.2 (which presumably you were on before, and worked in this respect):

https://github.com/dotmailer/dotdigital-signup-form/compare/v6.0.2...v6.0.3#diff-d2ab9925cad7eac58e0ff4cc0d251a937ecf49e4b6bf57f8b95aab76648a9d34

I've highlighted the specific changes we made to composer.json.

v6.0.3 of the plugin comes bundled with v2.0.0-RC1 of our SDK, diff here too:

https://github.com/dotmailer/dotdigital-php/compare/master...develop#diff-d2ab9925cad7eac58e0ff4cc0d251a937ecf49e4b6bf57f8b95aab76648a9d34

Perhaps we also need to set "php-http/discovery": false there as well.

sta1r commented 1 year ago

One other thing to try:

sta1r commented 1 year ago

I've pushed up the above suggestions to a new branch: https://github.com/dotmailer/dotdigital-signup-form/tree/AM/216205-package-update

Perhaps you could try this out on your system at some point? Thanks

sta1r commented 1 year ago

@codepuncher Hi again - we've released a new version with namespace scoping. See https://github.com/dotmailer/dotdigital-for-wordpress/commit/a87afef79518912bfeab29d3b50d2ee1b78ba348. A namespace clash could have been responsible for your issue, based on your June 27 comment.