In our legacy PayPal code we have a function that is supposed to set meta when the customer lands on the order received page.
The logic at the top of the function has a gap and can lead to the following error:
PHP Warning: Undefined array key "order-received" in /public/wp-content/plugins/woocommerce-subscriptions-core/includes/gateways/paypal/class-wcs-paypal.php on line 519
This can occur because our wcs_is_order_received_page() just checks if order-received is anywhere in the URI.
wcs_is_order_received_page() has a function comment which indicates that checking the URI is by design. It's supposed to be used in cases where we want to check if the request is for the order received without accessing the $wp->query_vars. In this case we need to access the $wp->query_vars to pull the order ID and so it's not a good candidate for this.
This PR fixes that.
How to test this PR
[!note]
I'm not sure how folks are replicating this natively, whenever I go to a legit order received page, it pulls the order ID out of the URL just fine.
Go to the front page of your store and add the order-recieved query var.
On trunk you should get the error I mentioned above. On this branch there will be no error.
Confirm that the order received page still works as intended.
eg Add a breakpoint or logging to the maybe_add_payment_lock() function and verify that the $order param is still being loaded eg add a $order->get_id().
Purchase a new product of any type and confirm via the breakpoint or logging that you added that the order is still loading and that maybe_add_payment_lock() would still work as intended.
Product impact
[x] Added changelog entry (or does not apply)
[ ] Will this PR affect WooCommerce Subscriptions? yes/no/tbc, add issue ref
[ ] Will this PR affect WooCommerce Payments? yes/no/tbc, add issue ref
[ ] Added deprecated functions, hooks or classes to the spreadsheet
Fixes #418
Description
In our legacy PayPal code we have a function that is supposed to set meta when the customer lands on the order received page.
The logic at the top of the function has a gap and can lead to the following error:
This can occur because our
wcs_is_order_received_page()
just checks iforder-received
is anywhere in the URI.wcs_is_order_received_page()
has a function comment which indicates that checking the URI is by design. It's supposed to be used in cases where we want to check if the request is for the order received without accessing the$wp->query_vars
. In this case we need to access the$wp->query_vars
to pull the order ID and so it's not a good candidate for this.This PR fixes that.
How to test this PR
order-recieved
query var.trunk
you should get the error I mentioned above. On this branch there will be no error.maybe_add_payment_lock()
function and verify that the$order
param is still being loaded eg add a$order->get_id()
.maybe_add_payment_lock()
would still work as intended.Product impact