[wp-trac] [WordPress Trac] #32223: Events in wp_publish_post fire are in an unnatural order

WordPress Trac noreply at wordpress.org
Fri May 1 11:52:25 UTC 2015


#32223: Events in wp_publish_post fire are in an unnatural order
-------------------------------+-----------------------------
 Reporter:  Clorith            |      Owner:
     Type:  defect (bug)       |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:  2.3
 Severity:  normal             |   Keywords:
  Focuses:                     |
-------------------------------+-----------------------------
 The post status is transitioned with `wp_transition_post_status` very
 early on in the function call.

 The trouble with this is that `edit_post`, `save_post` and similar actions
 do not fire until the post has transitioned and essentially relevant post
 data does not yet exist when a post is published.

 It's a short period between the post status being updated and other events
 triggering, but it is an unnatural order, and does not allow for proper
 interaction when hooking into other features such as `publish_post` for
 example.

 This ordering has existed for some time though, so do we fix it, or leave
 it?

 I'm not seeing any obvious drawbacks to making the transition call be the
 final step in publishing a post, it feels like a more natural progression.

 Attached patch does just that, it moved the query to update post status,
 the cache clear and the transition call to run after we're done saving our
 post data

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


More information about the wp-trac mailing list