pronamic/wp-pay-core

Subscription post `post_status` cannot be `null`

Closed this issue · 1 comments

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:

if ( ! isset( $data['post_status'] ) || 'trash' !== $data['post_status'] ) {
$data['post_status'] = $this->get_post_status_from_meta_status( $subscription->get_status() );
}

/**
* Get post status from meta status.
*
* @param string|null $meta_status Meta status.
* @return string|null
*/
private function get_post_status_from_meta_status( $meta_status ) {
if ( null === $meta_status ) {
return null;
}
if ( isset( $this->status_map[ $meta_status ] ) ) {
return $this->status_map[ $meta_status ];
}
return null;
}

The changes in #159 seem to have solved the problem, see also the internal HelpScout ticket: https://secure.helpscout.net/conversation/2357245448/26133/.