[wp-hackers] apply_filters, merge_filters and reset()
Travis Snoozy
ai2097 at users.sourceforge.net
Thu Nov 8 04:50:56 GMT 2007
On Wed, 07 Nov 2007 19:49:57 -0600, Jacob <wordpress at santosj.name>
wrote:
<snip>
> I've been following the current Plugin API bugs and enhancements and
> I would hold off on that if I were you.
>
> http://trac.wordpress.org/ticket/5231
> http://trac.wordpress.org/ticket/5232
For the record, these concern trunk/2.4, not 2.3.1. The discussion
about separating filters/actions is interesting, but there still
may need to be a simpler bugfix applied to 2.3.2 (e.g., always call
merge_filters, or at least always reset the array). I'll have to re-run
perf on a 2.4 beta/RC anyway. ;)
> I think there might be a good reason to not use foreach in that
> function because of the inter references and possible changes. If you
> add a tag while iterating, you will break the array reference and it
> would need to be reset anyway.
<snip>
I assume you mean "a filter/action adds/removes hooks" when you say
"add a tag while iterating". That's a valid point; I'd need to test and
make sure that it still works (I know I have some plugin code somewhere
that does just this by hooking a high level and de-hooking a
lower-level callback). I'm not entirely confident that each() really
behaves any more consistently than foreach in that scenario, though.
> And yes, if you read the reports, the do_action and companion should
> have checked for the tag in merged_filters before calling
> merge_filters function.
Which would indicate that they're all buggy, since they rely on the
reset side-effect of merged_filters to get the array pointer back to
the start, and nothing else (as far as I can see) resets that array.
--
Travis
In Series maintainer
Random coder & quality guy
<http://remstate.com/>
More information about the wp-hackers
mailing list