[wp-trac] [WordPress Trac] #21169: remove_action on a tag within do_action for that tag can cause actions to be missed

WordPress Trac wp-trac at lists.automattic.com
Thu Jul 5 21:08:23 UTC 2012


#21169: remove_action on a tag within do_action for that tag can cause actions to
be missed
--------------------------+-----------------------------
 Reporter:  devesine      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Plugins       |    Version:
 Severity:  major         |   Keywords:  has-patch
--------------------------+-----------------------------
 '''Problem:'''

 If an action (or filter) in a given priority for a given tag removes
 itself as part of its execution, and it was the only action/filter at that
 priority for that tag (or only one remaining), the next priority level is
 skipped.

 '''Reproduction:'''

 See the attached unit test.

 '''Analysis:'''

 This appears to possibly be a bug (or at least an undocumented feature) of
 PHP (tested up to 5.4.3), where next() falls over if the current array
 element is unset (but each() has no problem even if the /next/ array
 element is unset).  Example non-WP code demonstrating this is included.

 '''Proposed solution / workaround:'''

 Switch all uses of next() in plugin.php to use each() instead; I've
 included a proposed patch.

 Props to smathiascrowdfavorite for bringing this bug to my attention.

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


More information about the wp-trac mailing list