[wp-trac] [WordPress Trac] #9886: Pass $this as the second argument in WP_Query filters

WordPress Trac wp-trac at lists.automattic.com
Tue Feb 23 23:40:43 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 scribu):

 > Have you tested this on PHP4.

 No, I haven't.

 Worst case, the callback receives a copy of the object, which means it can
 only read the properties and not modify them.

 > I think we still need to have the apply_filters_ref_array() function -
 this wouldn't need &$this to be it's first argument.

 You mean {{{apply_filters_ref_array('filter_name', $value, &$this)}}} ?

 I guess that could work. I was worried that you couldn't add extra
 parameters, but it actually makes more sense this way.


 Replying to [comment:19 filosofo]:
 > Will setting a variable within an object to point that object itself
 create garbage collection issues?  It sounds sketchy, at least.

 That's exactly what's happening in do_action_ref_array() and there haven't
 been any issues that I've heard of.

 > Couldn't you just pass the query arguments instead?

 Yes, passing the query_vars array would be the next best thing.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/9886#comment:20>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list