[wp-trac] [WordPress Trac] #19015: do_action fails on nested calls

WordPress Trac wp-trac at lists.automattic.com
Thu Oct 20 15:32:23 UTC 2011


#19015: do_action fails on nested calls
--------------------------+-----------------------------
 Reporter:  mrubiolvn     |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Plugins       |    Version:  3.2.1
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 I'll explain directly with an example of the scenario, for better
 understanding I hope.

 A function registered through add_action('save_post','callme_back');

 with the following code:

 {{{
 function callme_back($postId) {
     static $runmeOnce=true;
    if ($runmeOnce) {
      $runmeOnce = false;
      wp_insert_post(get_post(21431/*whatever, just to trigger save_post
 again*/));
     }
 }
 }}}

 causes the internal array pointer of $wp_filter[ $tag ] to skip all
 the remaining calls to the filters for $postId, as a result of having
 already called all of them for $postId+1 and reached the end of the
 pointer.

 A solution is making a copy of $wp_filter[ $tag ] first.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/19015>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list