Automattic / woocommerce-subscriptions-core

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

Type checking #516

Open WillBrubaker opened 9 months ago

WillBrubaker commented 9 months ago

Describe the bug

A cart session can end up in a state where line_item_id no longer exists. This results in a PHP fatal error (or warning depending on PHP version)

To Reproduce

  1. Have a renewal in the cart
  2. Maybe logout. Something happens to the session data such that line_itemid is removed ¯_(ツ)
  3. Presumably log back in and continue on with trying to complete checkout with the renewal
  4. Depending on PHP version:
    [25-Sep-2023 13:16:58 UTC] PHP Notice:  Undefined offset: 7777777 in /apps/no-pong/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/includes/class-wcs-cart-renewal.php on line 433
    [25-Sep-2023 13:16:58 UTC] PHP Notice:  Trying to access array offset on value of type null in /apps/no-pong/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/includes/class-wcs-cart-renewal.php on line 435
    [25-Sep-2023 13:16:58 UTC] PHP Notice:  Trying to access array offset on value of type null in /apps/no-pong/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/includes/class-wcs-cart-renewal.php on line 450
    [25-Sep-2023 13:16:58 UTC] PHP Notice:  Trying to access array offset on value of type null in /apps/no-pong/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/includes/class-wcs-cart-renewal.php on line 450
    [25-Sep-2023 13:16:58 UTC] PHP Warning:  array_sum() expects parameter 1 to be array, null given in /apps/no-pong/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/includes/class-wcs-cart-renewal.php on line 450

Or a fatal error for similar.

Expected behavior

A WooCommerce notice or something less brutal than a fatal error.

Actual behavior

Product impact

Additional context

7072656-zen