[wp-trac] [WordPress Trac] #23035: do_action() can't be nested because of global variable

WordPress Trac noreply at wordpress.org
Fri Dec 21 11:17:38 UTC 2012


#23035: do_action() can't be nested because of global variable
--------------------------+------------------------
 Reporter:  cheeserolls   |       Owner:
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  Plugins       |     Version:  3.5
 Severity:  normal        |  Resolution:  duplicate
 Keywords:  has-patch     |
--------------------------+------------------------

Comment (by cheeserolls):

 Replying to [comment:1 toscho]:
 > > However, saving the duplicates, causes the 'save_post' action to be
 triggered again.
 >
 > But that’s a bug in the plugin code, not in WordPress. To avoid that
 just remove the action on the first call inside of the function body:
 >
 >
 > {{{
 > remove_action( current_filter(), __FUNCTION__ );
 > }}}


 Not a bug in the plugin code.  The plugin code just calls
 wp_update_post().  How can a plugin author be expected to know that
 wp_update_post() will break the currently executing queue of actions?

 Anyway, you're talking about a specific example.  Even if the specific
 plugin was patched, the general problem still exists.  You should be able
 to safely call standard wordpress functions within an action, without any
 danger that the current action will break.

 Sergey correctly identified this as a duplicate of
 http://core.trac.wordpress.org/ticket/17817 where foo123 proposed
 essentially the same solution as me.

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


More information about the wp-trac mailing list