[wp-trac] [WordPress Trac] #31316: wp_list_pluck unexpectedly returns id indexed array instead of plucked values with index_key = null
WordPress Trac
noreply at wordpress.org
Fri Feb 13 02:54:03 UTC 2015
#31316: wp_list_pluck unexpectedly returns id indexed array instead of plucked
values with index_key = null
------------------------------------+------------------------------
Reporter: adamsilverstein | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.1
Severity: normal | Resolution:
Keywords: has-patch dev-feedback | Focuses:
------------------------------------+------------------------------
Comment (by boonebgorges):
I came here to say that we probably can't change this for backward
compatibility reasons, but dd32 beat me to it :) I don't disagree that the
behavior is a bit odd with numeric keys, but it's very likely that there
are plugins that are expecting to have the keys preserved. In the case of
associative arrays, it would be bad indeed if this behavior were changed.
It's worth noting that PHP's `array_filter()` preserves keys in the same
way as `wp_list_pluck()`, but `array_column()` does not.
I do think it's worth adding a line to the docblock explaining the current
behavior.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/31316#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list