pronamic / wp-pay-core

Core components for the WordPress payment processing library. This library is used in the WordPress plugin Pronamic Pay: https://www.pronamicpay.com/, but also allows other plugin developers to set up a payment plugin.
https://www.wp-pay.org/
GNU General Public License v3.0
27 stars 3 forks source link

Subscription post `post_status` cannot be `null` #158

Closed remcotolsma closed 10 months ago

remcotolsma commented 10 months ago

We just encountered the following error message with WP Rocket:

[25-Oct-2023 13:01:01 UTC] PHP Fatal error:  Uncaught TypeError: Argument 1 passed to WP_Rocket\Engine\Preload\Subscriber::remove_private_post() must be of the type string, null given, called in /home/customer/www/example.com/public_html/wp-includes/class-wp-hook.php on line 310 and defined in /home/customer/www/example.com/public_html/wp-content/plugins/wp-rocket/inc/Engine/Preload/Subscriber.php:467
Stack trace:
#0 /home/customer/www/example.com/public_html/wp-includes/class-wp-hook.php(310): WP_Rocket\Engine\Preload\Subscriber->remove_private_post(NULL, 'subscr_pending', Object(WP_Post))
#1 /home/customer/www/example.com/public_html/wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters(false, Array)
#2 /home/customer/www/example.com/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#3 /home/customer/www/example.com/public_html/wp-includes/post.php(5383): do_action('transition_post...', NULL, 'subscr_pending', Object(WP_Post))
#4 /home/customer/www/example.com/public_html/wp-includes/post.php(4643): wp_transition_post_status(NULL, 'subscr_pend in /home/customer/www/example.com/public_html/wp-content/plugins/wp-rocket/inc/Engine/Preload/Subscriber.php on line 467

Internal HelpScout ticket: https://secure.helpscout.net/conversation/2357245448/26133?folderId=1425710

After some research, this could be caused by this library:

https://github.com/pronamic/wp-pay-core/blob/68e947335aaf02544109862c4f3c685bfa8df9a9/src/Subscriptions/SubscriptionsDataStoreCPT.php#L182-L184

https://github.com/pronamic/wp-pay-core/blob/68e947335aaf02544109862c4f3c685bfa8df9a9/src/Subscriptions/SubscriptionsDataStoreCPT.php#L119-L135

remcotolsma commented 10 months ago

The changes in https://github.com/pronamic/wp-pay-core/pull/159 seem to have solved the problem, see also the internal HelpScout ticket: https://secure.helpscout.net/conversation/2357245448/26133/.