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

Ensure that no fatal error occurs while processing a subscription renewal when the object is stored in the subscription's metadata. #733

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

iamdharmesh
Copy link

Summary

We recently received a report from a customer that a subscription renewal fails with a fatal error when HPOS is enabled. Upon investigation, we found that this was caused by another extension on the site setting a WC_Cart object in the subscription's metadata, leading to a fatal error being thrown from our do_not_copy_order_meta function.

While storing objects in metadata is unusual, as part of defensive programming, it is better to add a check to ensure the data is valid before verifying whether a specific key exists. This PR makes a minor change to ensure that $meta is an array before checking if $meta['meta_key'] is set.

Fatal error:

ERROR scheduled action 11656188 (subscription payment) failed to finish processing due to the following exception: Cannot use object of type WC_Cart as array in /wp-content/plugins/woocommerce-gateway-paypal-powered-by-braintree/vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/integrations/class-sv-wc-payment-gateway-integration-subscriptions.php:450

UI Changes

N/A

QA

  1. Purchase a subscription product.
  2. Add any object to the subscription's metadata.
  3. Go to Edit Subscription, select "Process Renewal" from the order actions, and submit.
  4. Verify that the subscription renewal is processed successfully without a fatal error.

Before merge

  • I have confirmed these changes in each supported minor WooCommerce version

…al when the object is stored in the subscription's metadata.
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.

1 participant