Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getallheaders() Fallback #41

Merged
merged 1 commit into from
Sep 30, 2020
Merged

Conversation

websupporter
Copy link
Member

This PR fixes #37 by adding a getallheaders() fallback via https://github.com/ralouphie/getallheaders

@websupporter websupporter added this to the 1.0 milestone Sep 25, 2020
@mattallan
Copy link
Contributor

mattallan commented Sep 29, 2020

Hey @websupporter thanks for the PR
Unforunately I'm still seeing a bunch of these errors while testing on this branch:

2020-09-29T02:10:45+00:00 CRITICAL Uncaught Error: Call to undefined function WooCommerce\PayPalCommerce\ApiClient\Endpoint\getallheaders() in /srv/users/usercb6924e6/apps/usercb6924e6/public/wp-content/plugins/paypal-for-woocommerce/modules/ppcp-api-client/src/Endpoint/class-webhookendpoint.php:267
Stack trace:
#0 /srv/users/usercb6924e6/apps/usercb6924e6/public/wp-content/plugins/paypal-for-woocommerce/modules/ppcp-webhooks/src/class-incomingwebhookendpoint.php(122): WooCommerce\PayPalCommerce\ApiClient\Endpoint\WebhookEndpoint->verify_current_request_for_webhook(Object(WooCommerce\PayPalCommerce\ApiClient\Entity\Webhook))
#1 /srv/users/usercb6924e6/apps/usercb6924e6/public/wp-includes/rest-api/class-wp-rest-server.php(1016): WooCommerce\PayPalCommerce\Webhooks\IncomingWebhookEndpoint->verify_request(Object(WP_REST_Request))
#2 /srv/users/usercb6924e6/apps/usercb6924e6/public/wp-includes/rest-api/class-wp-rest-server.php(376): WP_REST_Server->dispatch(Object(WP_REST_Request))
#3 /srv/users/usercb6924e6/apps/usercb6924e6/public/wp-includes/re in /srv/users/usercb6924e6/apps/usercb6924e6/public/wp-content/plugins/paypal-for-woocommerce/modules/ppcp-api-client/src/Endpoint/class-webhookendpoint.php on line 267

2020-09-29T02:11:17+00:00 CRITICAL Uncaught Error: Call to undefined function WooCommerce\PayPalCommerce\ApiClient\Endpoint\getallheaders() in /srv/users/usercb6924e6/apps/usercb6924e6/public/wp-content/plugins/paypal-for-woocommerce/modules/ppcp-api-client/src/Endpoint/class-webhookendpoint.php:267
Stack trace:
#0 /srv/users/usercb6924e6/apps/usercb6924e6/public/wp-content/plugins/paypal-for-woocommerce/modules/ppcp-webhooks/src/class-incomingwebhookendpoint.php(122): WooCommerce\PayPalCommerce\ApiClient\Endpoint\WebhookEndpoint->verify_current_request_for_webhook(Object(WooCommerce\PayPalCommerce\ApiClient\Entity\Webhook))
#1 /srv/users/usercb6924e6/apps/usercb6924e6/public/wp-includes/rest-api/class-wp-rest-server.php(1016): WooCommerce\PayPalCommerce\Webhooks\IncomingWebhookEndpoint->verify_request(Object(WP_REST_Request))
#2 /srv/users/usercb6924e6/apps/usercb6924e6/public/wp-includes/rest-api/class-wp-rest-server.php(376): WP_REST_Server->dispatch(Object(WP_REST_Request))
#3 /srv/users/usercb6924e6/apps/usercb6924e6/public/wp-includes/re in /srv/users/usercb6924e6/apps/usercb6924e6/public/wp-content/plugins/paypal-for-woocommerce/modules/ppcp-api-client/src/Endpoint/class-webhookendpoint.php on line 267

The logs appear to be delayed/randomly so it's hard to pin-point exactly how to reproduce, but all i'm doing is adding a product to the cart and staying on the product page.

Out of curiosity, have you been able to replicate this one?

If not, I can create an admin account for my test store that is seeing the issue.

@mattallan mattallan self-assigned this Sep 29, 2020
@websupporter
Copy link
Member Author

Hi @mattallan,
no, I couldn't replicate the problem as my PHP version has getallheaders(). Will dig a bit how to set up an environment without this function. I wonder why composer install or composer update didn't show any effect 🤔

This function is used in the webhooks, this is why it might seem random. It is called when PayPal calls one of those webhooks.

@mattallan
Copy link
Contributor

I wonder why composer install or composer update didn't show any effect

Aha! My bad, I didn't even realise the package wasn't being installed properly in my testing. I ran composer update but that wasn't working because the phpunit version we have set (^9.1) requires PHP 7.3+ and I'm running 72:

I changed this to a previous phpunit version and now it's all working as expected now.
I haven't seen the undefined function pop up anymore so I think this is fine to merge.

I'm not sure if you wanted to change the phpunit versions in composer or leave it, but I'm fine to manage this version compatibility issue manually for now.

👍 thanks for the fix!

@mattallan mattallan merged commit d28f763 into master Sep 30, 2020
@AlexP11223 AlexP11223 deleted the issue-37-getallheaders-fallback branch August 1, 2022 06:28
@Mr-Aspirapolvere Mr-Aspirapolvere mentioned this pull request Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

undefined function WooCommerce\PayPalCommerce\ApiClient\Endpoint\getallheaders()
2 participants