[wp-trac] [WordPress Trac] #45114: Fire publishing related hooks after all data is saved via the REST API.

WordPress Trac noreply at wordpress.org
Thu Sep 24 15:12:18 UTC 2020


#45114: Fire publishing related hooks after all data is saved via the REST API.
---------------------------+-----------------------
 Reporter:  peterwilsoncc  |       Owner:  (none)
     Type:  defect (bug)   |      Status:  reopened
 Priority:  normal         |   Milestone:  5.6
Component:  REST API       |     Version:
 Severity:  normal         |  Resolution:
 Keywords:  dev-feedback   |     Focuses:
---------------------------+-----------------------

Comment (by TimothyBlynJacobs):

 My general thoughts are that using the `save_post` hook to fire those
 types of actions that require the full state of the post immediately isn't
 the best way to do it.

 Any instance where all the post data can't be added via `wp_insert_post`
 arguments will be affected by this. Which is why in my mind when you need
 the absolute completed state of the object, and the action performed is
 final ( you aren't listening for hooks to sync things ), then `save_post`
 should be used as an indicator that a new post is coming and be queued for
 action, but not immediately processed following a pattern similar to what
 I outlined in comment:27.

 This would allow the REST API publishing case to be fixed, but it means
 the underlying problem wouldn't be fixed.

 ----

 Now, if we do want to make that change anyways.

 > is it too late to fix this back-compat change?

 I don't think it is too late assuming we don't cause breakage of the
 plugins that have implemented alternatives like listening for
 `rest_after_insert_`.

 > would a _fix_ end up breaking a bunch of plugins?

 I think this could be a possibility and the breakage might be subtle
 which would be particularly annoying.

 > rubber-ducking how this could break things.

 One possibility would be if developers are expecting a post to have been
 created first ( and listening for it with `save_post` ), before their
 callbacks that are attached to meta or term updates are fired.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/45114#comment:30>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list