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

WordPress Trac wp-trac at lists.automattic.com
Fri Sep 14 10:37:20 UTC 2012


#17817: do_action/apply_filters/etc. recursion on same filter kills underlying call
-------------------------+------------------------------
 Reporter:  kernfel      |       Owner:
     Type:  enhancement  |      Status:  reopened
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Plugins      |     Version:  3.4.1
 Severity:  minor        |  Resolution:
 Keywords:  2nd-opinion  |
-------------------------+------------------------------
Changes (by foo123):

 * keywords:   => 2nd-opinion
 * version:   => 3.4.1
 * type:  defect (bug) => enhancement


Comment:

 another solution while retaining internal pointers is to use a dummy
 variable (since this would duplicate the intrnal pointer , according to
 PHP docs)

 {{{
 $foo=$wp_filter[ $tag ];
 reset( $foo );

 if ( empty($args) )
         $args = func_get_args();

 do {
         foreach( (array) current($foo) as $the_ )
                 if ( !is_null($the_['function']) ){
                         $args[1] = $value;
                         $value = call_user_func_array($the_['function'],
 array_slice($args, 1, (int) $the_['accepted_args']));
                 }

 } while ( next($foo) !== false );
 }}}

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


More information about the wp-trac mailing list