[wp-trac] [WordPress Trac] #16895: wp_list_pluck cannot be used with arrays of references

WordPress Trac wp-trac at lists.automattic.com
Tue Mar 22 16:51:35 UTC 2011


#16895: wp_list_pluck cannot be used with arrays of references
-------------------------+-----------------------------
 Reporter:  dd32         |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Future Release
Component:  General      |     Version:  3.1
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |
-------------------------+-----------------------------

Comment (by hakre):

 Replying to [comment:12 dd32]:
 > > But I still can not see how that should apply to $wp_query->comments
 (I didn't
 > get it filled in my test script either, just asking).
 >
 > If you tested on a page which might possibly have it set, you'd find
 it's an
 > array of references to arrays.
 >
 > For readability, I'd prefer to have the output list separate from the
 input
 > list, rather than just juggling PHP reference's.

 Well it's actually not juggling and normally foreach opereates on a copy
 of the array ...

 >
 > The other thing which this will protect against is a reference to an
 array being
 > passed in to $list, which while deprecated in PHP (Call-time pass-by-
 reference)
 > some developers may still do.

 ... but not in that case, right.

 As references are so popular, one could argue that the function should
 properly take over referenced values in the fields as well.

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


More information about the wp-trac mailing list