Automattic / woocommerce-subscriptions-core

Subscriptions core package for WooCommerce
Other
81 stars 29 forks source link

Address PHP 8.2 Warnings #528

Closed mattallan closed 8 months ago

mattallan commented 8 months ago

Fixes #325

Description

After updating to PHP 8.2 there are a number of warnings coming from Subscriptions Core files:

[13-Oct-2023 02:38:45 UTC] PHP Deprecated:  Creation of dynamic property WCS_Email_Completed_Renewal_Order::$heading_downloadable is deprecated in /Users/matt/local/woo/wp-content/plugins/woocommerce-subscriptions-core/includes/emails/class-wcs-email-completed-renewal-order.php on line 38
[13-Oct-2023 02:38:45 UTC] PHP Deprecated:  Creation of dynamic property WCS_Email_Completed_Renewal_Order::$subject_downloadable is deprecated in /Users/matt/local/woo/wp-content/plugins/woocommerce-subscriptions-core/includes/emails/class-wcs-email-completed-renewal-order.php on line 40
[13-Oct-2023 02:38:45 UTC] PHP Deprecated:  Creation of dynamic property WCS_Email_Completed_Switch_Order::$heading_downloadable is deprecated in /Users/matt/local/woo/wp-content/plugins/woocommerce-subscriptions-core/includes/emails/class-wcs-email-completed-switch-order.php on line 38
[13-Oct-2023 02:38:45 UTC] PHP Deprecated:  Creation of dynamic property WCS_Email_Completed_Switch_Order::$subject_downloadable is deprecated in /Users/matt/local/woo/wp-content/plugins/woocommerce-subscriptions-core/includes/emails/class-wcs-email-completed-switch-order.php on line 39
[13-Oct-2023 02:38:45 UTC] PHP Deprecated:  Creation of dynamic property WCS_Email_New_Switch_Order::$subscriptions is deprecated in /Users/matt/local/woo/wp-content/plugins/woocommerce-subscriptions-core/includes/emails/class-wcs-email-new-switch-order.php on line 95
[13-Oct-2023 02:38:45 UTC] PHP Deprecated:  Creation of dynamic property WCS_Email_Completed_Switch_Order::$subscriptions is deprecated in /Users/matt/local/woo/wp-content/plugins/woocommerce-subscriptions-core/includes/emails/class-wcs-email-completed-switch-order.php on line 99

The $heading_downloadable and $subject_downloadable parameters were removed in WooCommerce 3.1 (see https://github.com/woocommerce/woocommerce/commit/adc679633bdb627bbebab5c0f537e5dad856ca4e) so I've opted to deprecate and remove these parameters but maintain backward compatibility using __get() function.

How to test this PR

  1. Update your local dev environment to PHP 8.2 and enable WP_DEBUG
  2. Make sure you have Woo Subscriptions installed and active
  3. Enable Completed Renewal Order and Completed Switch Order emails
  4. Process a switch and confirm the emails were sent properly.
  5. On trunk you will see the above warnings
  6. On this branch you shouldn't see any deprecation warnings coming from subscriptions-core

Product impact