[wp-trac] [WordPress Trac] #57589: transition_post_status hook does not fire when cron publishes scheduled post.

WordPress Trac noreply at wordpress.org
Mon Jan 30 22:32:39 UTC 2023


#57589: transition_post_status hook does not fire when cron publishes scheduled
post.
--------------------------+-----------------------------
 Reporter:  tele2rn       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Cron API      |    Version:  6.1.1
 Severity:  major         |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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):
 - * * * * * wget -q -O - --no-check-certificate https://domain.com/wp-
 cron.php?doing_wp_cron >/dev/null 2>&1
 - * * * * * cd /path/to/www; /usr/local/bin/wp cron event run --due-now
 >/dev/null 2>&1

 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!

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57589>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list