Automattic / woocommerce-subscriptions-core

Subscriptions core package for WooCommerce
Other
85 stars 31 forks source link

[HPOS] Manually adding a subscription results in a PHP Warning: Undefined array key "start" #361

Closed james-allan closed 1 year ago

james-allan commented 1 year ago

Describe the bug

On HPOS environments, new subscriptions created via the edit admin screen result in the following error:

PHP Warning:  Undefined array key "start" in public/wp-content/plugins/woocommerce-subscriptions-core/includes/class-wc-subscription.php on line 2459
PHP Stack trace:
PHP   1. {main}() public/wp-admin/admin.php:0
PHP   2. do_action() public/wp-admin/admin.php:259
PHP   3. WP_Hook->do_action() public/wp-includes/plugin.php:517
PHP   4. WP_Hook->apply_filters() public/wp-includes/class-wp-hook.php:332
PHP   5. Automattic\WooCommerce\Internal\Admin\Orders\PageController->output() public/wp-includes/class-wp-hook.php:308
PHP   6. Automattic\WooCommerce\Internal\Admin\Orders\Edit->setup() public/wp-content/plugins/woocommerce/src/Internal/Admin/Orders/PageController.php:212
PHP   7. Automattic\WooCommerce\Internal\Admin\Orders\Edit->handle_order_update() public/wp-content/plugins/woocommerce/src/Internal/Admin/Orders/Edit.php:99
PHP   8. do_action() public/wp-content/plugins/woocommerce/src/Internal/Admin/Orders/Edit.php:152
PHP   9. WP_Hook->do_action() public/wp-includes/plugin.php:517
PHP  10. WP_Hook->apply_filters() public/wp-includes/class-wp-hook.php:332
PHP  11. WCS_Meta_Box_Subscription_Data::save() public/wp-includes/class-wp-hook.php:308
PHP  12. WC_Subscription->update_status() public/wp-content/plugins/woocommerce-subscriptions-core/includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:426
PHP  13. WC_Subscription->update_dates() public/wp-content/plugins/woocommerce-subscriptions-core/includes/class-wc-subscription.php:493
PHP  14. WC_Subscription->validate_date_updates() public/wp-content/plugins/woocommerce-subscriptions-core/includes/class-wc-subscription.php:1273

To Reproduce

  1. Enable HPOS tables.
  2. Go to WooCommerce > Subscriptions > Add new
  3. Note the subscription start date is empty.
  4. Add items, a customer etc and click Save.
  5. You should get the error message mentioned above.

Expected behavior

Actual behavior

Product impact

Additional context