Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#32223 closed enhancement (wontfix)

Hooks in wp_publish_post fire in an unnatural order

Reported by: clorith's profile Clorith Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.3
Component: Posts, Post Types Keywords: has-patch
Focuses: Cc:

Description

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

Attachments (1)

32223.patch (1.1 KB) - added by Clorith 9 years ago.

Download all attachments as: .zip

Change History (3)

@Clorith
9 years ago

#1 @Clorith
9 years ago

  • Summary changed from Events in wp_publish_post fire are in an unnatural order to Hooks in wp_publish_post fire in an unnatural order

#2 in reply to: ↑ description @DrewAPicture
9 years ago

  • Keywords has-patch added
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed
  • Type changed from defect (bug) to enhancement

Replying to Clorith:

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

I think it's definitely too late to be changing the order around. It's quite reasonable to think that many developers are counting on these hooks to fire in their current order. Closing as wontfix.

Thank for the patch!

Note: See TracTickets for help on using tickets.