[wp-trac] [WordPress Trac] #34172: wp_list_pluck missing checks

WordPress Trac noreply at wordpress.org
Tue Oct 6 18:50:04 UTC 2015


#34172: wp_list_pluck missing checks
--------------------------+------------------------------
 Reporter:  wpsmith       |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:  performance
--------------------------+------------------------------

Comment (by boonebgorges):

 Yes, I've looked at the gist. My question is: What is the use case for
 looping over an array to fetch properties that don't exist on the items of
 the array? `wp_list_pluck()` is a utility function, a shortcut. If you're
 working with inconsistent data, such that you're unsure whether members of
 the array will have a given property, then you probably ought to be doing
 your own `foreach` loop that does any necessary error-checking.

 To put the same point another way, your patch assumes that
 `wp_list_pluck()` should simply skip items that don't have the specified
 property. But why should this be expected behavior? Why wouldn't you want
 `array( null, null )` returned?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/34172#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list