[wp-trac] [WordPress Trac] #17817: do_action/apply_filters/etc. recursion on same filter kills underlying call
WordPress Trac
noreply at wordpress.org
Wed Oct 8 22:21:01 UTC 2014
#17817: do_action/apply_filters/etc. recursion on same filter kills underlying call
-------------------------------------------------+-------------------------
Reporter: kernfel | Owner:
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: Future
Component: Plugins | Release
Severity: normal | Version: 2.2
Keywords: dev-feedback has-unit-tests has- | Resolution:
patch | Focuses:
-------------------------------------------------+-------------------------
Comment (by leewillis77):
Great to see this being worked on - I just wasted a good two hours trying
to work out why a hook wasn't being fired with this as the root cause (Not
in my code thankfully).
Good news - the patch here resolves the issue I was having. However - it
causes issues where there are multiple callbacks registered against a
hook, and an earlier hook accepts fewer arguments than a subsequent hook,
e.g.
{{{
add_action($tag, array(&$a1, 'action'), 10, 2);
add_action($tag, array(&$a2, 'action'));
add_action($tag, array(&$a3, 'action'), 10, 2);
}}}
In this situation, the third callback will only receive one argument, not
two. The revised patch attached resolves this, complete with a test to
prove it. I cannot for the life of me work out why though - it's as though
the array_slice is affecting $args (Which it shouldn't).
In my defense, it's late in the day though ...
So - this probably needs more work (At least we'd need to verify that
creating a copy of the args rather than reusing a reference doesn't impact
on performance (CPU or memory)), but throwing this out for discussion.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/17817#comment:72>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list