[wp-trac] [WordPress Trac] #17817: do_action/apply_filters/etc. recursion on same filter kills underlying call

WordPress Trac noreply at wordpress.org
Tue Apr 16 13:50:39 UTC 2013


#17817: do_action/apply_filters/etc. recursion on same filter kills underlying call
----------------------------------------+-----------------------
 Reporter:  kernfel                     |       Owner:
     Type:  defect (bug)                |      Status:  reopened
 Priority:  normal                      |   Milestone:  3.6
Component:  Plugins                     |     Version:  3.4.1
 Severity:  normal                      |  Resolution:
 Keywords:  has-patch needs-unit-tests  |
----------------------------------------+-----------------------
Changes (by jbrinley):

 * cc: jonathanbrinley@… (added)


Comment:

 I don't agree with this change. If you move to a foreach loop, you'll lose
 the ability to add another callback to the same hook with a later
 priority.

 {{{
 function my_first_callback( $post_id, $post ) {
   if ( $post->post_type == 'pistachio' ) {
     add_action('save_post', 'my_second_callback', 15, 2);
   }
 }
 function my_second_callback( $post_id, $post ) {
   // do something else
 }
 add_action('save_post', 'my_first_callback', 10, 2);
 }}}

 I had always assumed that having this ability was a conscious design
 decision, not a bug. Removing it would definitely break some plugins.

 I wrote a blog post a couple of years back about this issue
 (http://xplus3.net/2011/08/18/wordpress-action-nesting/), and the
 workaround is fairly simple. In my opinion, it should be up to a plugin
 author to take care of the housekeeping if he decides to nest action
 calls.

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


More information about the wp-trac mailing list