Make WordPress Core

Opened 18 months ago

Last modified 18 months ago

#57589 new defect (bug)

transition_post_status hook does not fire when cron publishes scheduled post.

Reported by: tele2rn's profile tele2rn Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.1.1
Component: Cron API Keywords: reporter-feedback
Focuses: Cc:

Description

Ever since the most recent 6.1 update, a critical hook of ours is not firing any more.

We have a custom cache clearing plugin that clears the nginx, redis and Cloudflare cache for a bunch of our landing pages. It runs on our site when a post's status changes from from 'future' to 'publish', from 'publish' to 'trash' or when a post is originally published of updated. We use the transition_post_status hook to trigger these cache clears.

Everything was working great until the 6.1/6.1.1 updates. After the wp 6.1 update, the manual publish/update operations done directly using the wp-admin work fine, but when our cron runs to publish a scheduled post the transition_post_status hook does not fire at all.

But here is the most curious thing... the "publish_future_post" cron job is not created when we schedule a post for the future. The function check_and_publish_future_post() uses this cron job to decide what posts need to be published, but the cron job never appears in my action scheduler or in my events tab of the wp-control plugin. So that mean that the wp_publish_post() function does not run, and the filter hooks don't fire. But the post DOES publishes as expected on the wp-cron. It is beyond weird, and i cant figure it out.

Here is what I have done and tested thus far:

I have tested all of the following hooks: none of them work either:

  • transition_post_status
  • future_to_publish
  • future_post

I am using a manual cron fired from my ubuntu server, and I have confirmed my cron is firing using an output.log, and I can also confirm that other wp-cron jobs are running as as normal.

I have tried both a conventional wget 'doing_wp_cron' and a wp-cli cron jobs, and both fail (see examples below):

In order to get back to where we were, I have had to spin up my own cron that publishes future posts myself, so I have solved this issue on my end, but I cannot be the only one experiencing this, so I thought that I would submit this information for your review, thanks!

Change History (2)

#1 @peterwilsoncc
18 months ago

  • Keywords reporter-feedback added
  • Severity changed from major to normal

Hi @tele2rn and welcome to trac!

I created a mini-plugin to test this issue and have not been able to reproduce the issue.

Running this plugin produced the expected log entries when the post was published as scheduled

[31-Jan-2023 00:40:01 UTC] PHP Notice:  transition_post_status in /vagrant/content/mu-plugins/nope-scheduled-post.php on line 5
[31-Jan-2023 00:40:01 UTC] PHP Notice:  future_to_publish in /vagrant/content/mu-plugins/nope-scheduled-post.php on line 6

Saving a scheduled post also produced the expected entries

[31-Jan-2023 00:46:37 UTC] PHP Notice:  transition_post_status in /vagrant/content/mu-plugins/nope-scheduled-post.php on line 5
[31-Jan-2023 00:46:37 UTC] PHP Notice:  future_post in /vagrant/content/mu-plugins/nope-scheduled-post.php on line 7

Are you able to reproduce the issue on a WordPress install running a default theme with only the test plugin installed?

#2 @tele2rn
18 months ago

Thanks Peter, for your prompt reply.

I have installed your plugin on my local site and it failed to fire, just like my other action hooks. I then installed your plugin on a vanilla install of wp running only 2021 theme..., and your plugin did trigger the error on that site.

So I have to assume that it is a plugin or theme code conflict causing this issue. Do you have any idea what would cause a this to happen. Another action filter on the same hook? what do you think? Thanks!

Last edited 18 months ago by tele2rn (previous) (diff)
Note: See TracTickets for help on using tickets.