Automattic / woocommerce-subscriptions-core

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

Invalid subscription_status passed into wcs_get_subscriptions() not ignored with HPOS #453

Closed prettyboymp closed 11 months ago

prettyboymp commented 1 year ago

Describe the bug

Passing in an invalid status for the subscription_status parameter` behaves differently when HPOS is enabled and when it is not.

While using the CPT storage, WP_Query filters out the invalid post_status resulting in no post_status where clause getting applied to the query causing any subscription status to be returned.

With HPOS, however, the clause for the order_status is still applied to the query, and results in no matching Subscriptions.

To Reproduce

This can be tested by running the test. See

https://github.com/Automattic/woocommerce-subscriptions-core/blob/1ce49cc29dc69baf681f15043143254d9423b896/tests/unit/test-wcs-functions.php#L1060

Running with HPOS will cause the count assertion to fail.

HPOS=1 ./vendor/bin/phpunit --filter=test_2_wcs_get_subscriptions