From 35257c2e2d7bcc1ba77b8e876cd5a974bf161880 Mon Sep 17 00:00:00 2001 From: whyisjake Date: Fri, 10 Jul 2020 00:31:06 +0000 Subject: [PATCH] Formatting: Ensure that wp_filter_object_list() will return an array when being passed an object with magic methods. Fixes #50095. Props johnjamesjacoby. Built from https://develop.svn.wordpress.org/trunk@48413 git-svn-id: http://core.svn.wordpress.org/trunk@48182 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-list-util.php | 19 +++++++++++++++---- wp-includes/version.php | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/wp-includes/class-wp-list-util.php b/wp-includes/class-wp-list-util.php index 3b1d328447..a09b119f2c 100644 --- a/wp-includes/class-wp-list-util.php +++ b/wp-includes/class-wp-list-util.php @@ -102,12 +102,23 @@ class WP_List_Util { $filtered = array(); foreach ( $this->output as $key => $obj ) { - $to_match = (array) $obj; - $matched = 0; + foreach ( $args as $m_key => $m_value ) { - if ( array_key_exists( $m_key, $to_match ) && $m_value == $to_match[ $m_key ] ) { - $matched++; + + if ( is_array( $obj ) ) { + + // Treat object as an array + if ( array_key_exists( $m_key, $obj ) && ( $m_value == $obj[ $m_key ] ) ) { + $matched++; + } + + } elseif ( is_object( $obj ) ) { + + // Treat object as an object + if ( isset( $obj->{$m_key} ) && ( $m_value == $obj->{$m_key} ) ) { + $matched++; + } } } diff --git a/wp-includes/version.php b/wp-includes/version.php index f31a9a563a..7a0b93923f 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-beta1-48412'; +$wp_version = '5.5-beta1-48413'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.