Automattic / woocommerce-payments

Accept payments via credit card. Manage transactions within WordPress.
https://wordpress.org/plugins/woocommerce-payments/
Other
174 stars 69 forks source link

Fatal errors when WC Subscriptions deactivated due to outdated version of WC #5623

Open brucealdridge opened 1 year ago

brucealdridge commented 1 year ago

Describe the bug

If WC Subscriptions detects an old version of WooCommerce's database it deactivates itself. The current existence check in WCPay for WC Subscriptions doesn't handle this case causing calls to classes and functions that aren't registered/loaded.

Fatal error: Uncaught Error: Class "WC_Subscriptions_Cart" not found
in woocommerce-payments/includes/compat/subscriptions/trait-wc-payments-subscriptions-utilities.php on line 87
Fatal error: Uncaught Error: Class 'WC_Subscriptions_Product' not found in woocommerce-
payments/includes/subscriptions/class-wc-payments-product-service.php:192

To Reproduce

Fatal errors can be triggered by manually updating $wc_minimum_required_version in woocommerce-subscriptions/woocommerce-subscriptions.php to something above the current WC version eg 7.5

Additional context

5924491-zd-woothemes 5921622-zd-woothemes https://wordpress.org/support/topic/fatal-error-4375/

WC Subscriptions has an open PR that will be merged and released shortly that changes the WC version detection from database-version to plugin-version. 4483-gh-woocommerce/woocommerce-subscriptions

haszari commented 1 year ago

Fatal error: Uncaught Error: Class "WC_Subscriptions_Cart" not found in woocommerce-payments/includes/compat/subscriptions/trait-wc-payments-subscriptions-utilities.php on line 87

Since the fatals are firing in WCPay code, at face value I'd first look at patching WCPay. i.e. hypothesis is that WCPay is executing subscriptions compat code when it shouldn't.