[wp-trac] [WordPress Trac] #9886: Pass $this as the second argument in WP_Query filters
WordPress Trac
wp-trac at lists.automattic.com
Thu Feb 25 20:31:49 UTC 2010
#9886: Pass $this as the second argument in WP_Query filters
-------------------------+--------------------------------------------------
Reporter: westi | Owner: westi
Type: enhancement | Status: new
Priority: normal | Milestone: 3.0
Component: Plugins | Version: 2.8
Severity: major | Keywords: has-patch commit early
-------------------------+--------------------------------------------------
Comment(by westi):
Replying to [comment:21 scribu]:
> Replying to [comment:18 westi]:
> > From memory you need to package the reference up in an array so that
you can pass it to a function which doesn't take a reference explicitly -
it have a variable length arguments list
>
> Here's what I've found while looking in wp-includes/plugin.php:
>
> do_action() contains these lines:
>
> {{{
> if ( is_array($arg) && 1 == count($arg) && is_object($arg[0]) ) //
array(&$this)
> $args[] =& $arg[0];
> }}}
>
This looks like do_action had some hacky code in it to do what
do_action_ref_array does before that existed.
> And here is the description for do_action_ref_array():
>
> {{{
> * Execute functions hooked on a specific action hook, specifying
arguments in an array.
> *
> * @see do_action() This function is identical, but the arguments passed
to the
> * functions hooked to <tt>$tag</tt> are supplied using an array.
> }}}
>
> So, either the docs are wrong or we're using do_action_ref_array()
wrong.
I don't see what is wrong here.
do_action_ref_array takes an array as an argument which can contain one or
more references.
This array is passed to call_user_func_array and ends up as a list of
normal arguments for the function hooked onto the relevant action.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/9886#comment:22>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list