Opened 12 years ago
Closed 9 years ago
#21172 closed defect (bug) (duplicate)
Adding the first filter/action in an earlier priority during a later priority causes the earlier priority to run (last)
Reported by: | devesine | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.4 |
Component: | Plugins | Keywords: | dev-feedback needs-refresh |
Focuses: | Cc: |
Description
During testing of #21169, it occurred to me that http://core.trac.wordpress.org/ticket/5338#comment:1 might present a problem with each rather than next/current, but that turns out not to be the case. Instead, this exposed a different bug:
If you add a new filter at priority 9, when priority 9 did not previously have any filters, during the priority 10 execution, the priority 9 filter will run (!) after all other priorities (since the filters are not resorted after each priority).
(Generally, if you add an earlier priority that did not previously have any filters during a later priority...)
The attached unit test demonstrates this behavior.
Attachments (3)
Change History (8)
Note: See
TracTickets for help on using
tickets.
Proposed solution: keep track of the current priority, skip any priorities encountered that are already past.
add-at-9-after-21169.patch applies after the patch attached to #21169; add-at-9-include-21169.patch includes that patch (for convenience of testing).
I can also write one against the present code (using
next()
/current()
rather thaneach()
) if/when that becomes appropriate. Doing it without the #21169 change would slightly change the implementation of this fix (to usekey($wp_filter[$tag])
instead of$next['key']
, I believe).