From 80494d2e8a1bb21a480115cd11e42c8ede978bdf Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 5 Jul 2023 11:13:26 +0000 Subject: [PATCH] General: Revert strict comparison in `WP_List_Util` for now. Casting the values to a string causes `Array to string conversion` PHP warnings, so using loose comparison restores the previous behavior for code relying on type juggling when using the `wp_list_filter()` function, e.g. comparing a numeric string to an integer. The unit test case added for this scenario in the previous commit remains. Follow-up to [55908], [56137]. See #57839. git-svn-id: https://develop.svn.wordpress.org/trunk@56138 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-list-util.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/wp-includes/class-wp-list-util.php b/src/wp-includes/class-wp-list-util.php index fbc171e0c6..c394f2c613 100644 --- a/src/wp-includes/class-wp-list-util.php +++ b/src/wp-includes/class-wp-list-util.php @@ -116,16 +116,12 @@ class WP_List_Util { foreach ( $args as $m_key => $m_value ) { if ( is_array( $obj ) ) { // Treat object as an array. - if ( array_key_exists( $m_key, $obj ) - && ( (string) $m_value === (string) $obj[ $m_key ] ) - ) { + 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} ) - && ( (string) $m_value === (string) $obj->{$m_key} ) - ) { + if ( isset( $obj->{$m_key} ) && ( $m_value == $obj->{$m_key} ) ) { $matched++; } } @@ -280,7 +276,7 @@ class WP_List_Util { continue; } - if ( (string) $a[ $field ] === (string) $b[ $field ] ) { + if ( $a[ $field ] == $b[ $field ] ) { continue; }