From 14e965a8d6be7524876ed2cfd52ddfcb5ca6fb4d Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Fri, 1 Apr 2022 05:56:06 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@53045 git-svn-id: http://core.svn.wordpress.org/trunk@52634 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 4 ++++ wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 7f57d234c1..ce28ff7a9a 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -5176,6 +5176,10 @@ function wp_list_filter( $list, $args = array(), $operator = 'AND' ) { * `$list` will be preserved in the results. */ function wp_list_pluck( $list, $field, $index_key = null ) { + if ( ! is_array( $list ) ) { + return array(); + } + $util = new WP_List_Util( $list ); return $util->pluck( $field, $index_key ); diff --git a/wp-includes/version.php b/wp-includes/version.php index e44aa07dcd..e05c4e13b6 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.0-alpha-53044'; +$wp_version = '6.0-alpha-53045'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.