Automattic / woocommerce-subscriptions-core

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

[HPOS] Undefined index when taking a parent order out of trash #502

Open a-danae opened 10 months ago

a-danae commented 10 months ago

Describe the bug

The following PHP notice appears in the logs when taking a parent order out of trash, and HPOS is enabled.

PHP Notice:  Undefined index: new in /var/www/html/wp-content/plugins/woocommerce-subscriptions-core/includes/class-wcs-object-data-cache-manager-many-to-one.php on line 36

To Reproduce

  1. Go to WooCommerce -> Settings -> Advanced -> Features. /wp-admin/admin.php?page=wc-settings&tab=advanced&section=features
  2. Under Experimental features, select "High performance order storage (new)", enable "Keep the posts and orders tables in sync (compatibility mode)", and save
  3. As a shopper, purchase a subscription
  4. As an admin, go to WooCommerce -> Orders
  5. Move the Parent order for the subscription you just purchased to trash
  6. Go to trash
  7. Restore the Parent order you just moved to trash
  8. Notice the PHP notice (ha!) in the debug.log file
PHP Notice:  Undefined index: new in /var/www/html/wp-content/plugins/woocommerce-subscriptions-core/includes/class-wcs-object-data-cache-manager-many-to-one.php on line 36

Expected behavior

Untrashing an order shouldn't trigger a PHP notice.

Actual behavior

Untrashing an order triggers a PHP notice.

Product impact

Additional context