remove_action on a tag within do_action for that tag can cause actions to be missed
|Reported by:||devesine||Owned by:|
|Component:||Plugins||Keywords:||has-patch needs-testing 3.6-early|
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.
See the attached unit test.
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.
Change History (29)
comment:15 follow-up: ↓ 16 nacin — 16 months ago
- Keywords 3.6-early added
- Milestone changed from 3.5 to Future Release