[wp-trac] [WordPress Trac] #23906: post_save callback is passed post instead of revision, breaking back-compat

WordPress Trac noreply at wordpress.org
Tue Apr 9 15:58:33 UTC 2013


#23906: post_save callback is passed post instead of revision, breaking back-compat
--------------------------+-------------------------
 Reporter:  iandunn       |       Owner:
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  Revisions     |     Version:  trunk
 Severity:  normal        |  Resolution:  worksforme
 Keywords:                |
--------------------------+-------------------------

Comment (by iandunn):

 The snippet above with the wp_die() call was just an example of how to
 reproduce the problem; you can view a real world example at
 http://pastebin.com/Et7VvABY.

 The save_post callback at that link is targeting the 'post' post type
 only, so it checks the value of $post->post_type and returns if it doesn't
 match. (In this case, $post refers to the object that was passed in as the
 2nd callback arg, not the global $post object).

 Is checking the post type on the passed post object the wrong way to
 achieve that? If so, I'm happy to update my plugins. I'm wondering if
 there's a significant number of other plugins that would also be affected,
 though.

 That callback in the link above is also intentionally only running on the
 first save_post call, which is just a general precaution I setup in most
 of my action callbacks. So, maybe this is only an issue when: 1) The
 save_post callback returns after the first run; and 2) The callback checks
 the value of the post_type on the object passed to the callback. If that's
 the case, then I would guess the number of plugins affected would be
 fairly small.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/23906#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list