Skip to content

Commit b0aefcf

Browse files
committed
General: Validate input of wp_list_pluck().
`wp_list_pluck()` is used by WordPress to pluck items from a list. Of course, this requires a list. This validates the input of `wp_list_pluck()` to ensure it is a list. This matches the behaviour of `wp_list_sort()` and `wp_filter_object_list()`. Props marv2, davidbaumwald, mkox, SergeyBiryukov, dd32. Fixes #54751. git-svn-id: https://develop.svn.wordpress.org/trunk@53045 602fd350-edb4-49c9-b593-d223f7449a82
1 parent a20c207 commit b0aefcf

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/wp-includes/functions.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5176,6 +5176,10 @@ function wp_list_filter( $list, $args = array(), $operator = 'AND' ) {
51765176
* `$list` will be preserved in the results.
51775177
*/
51785178
function wp_list_pluck( $list, $field, $index_key = null ) {
5179+
if ( ! is_array( $list ) ) {
5180+
return array();
5181+
}
5182+
51795183
$util = new WP_List_Util( $list );
51805184

51815185
return $util->pluck( $field, $index_key );

0 commit comments

Comments
 (0)