Make WordPress Core

Changeset 56138


Ignore:
Timestamp:
07/05/2023 11:13:26 AM (21 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-list-util.php

    r56137 r56138  
    117117                if ( is_array( $obj ) ) {
    118118                    // Treat object as an array.
    119                     if ( array_key_exists( $m_key, $obj )
    120                         && ( (string) $m_value === (string) $obj[ $m_key ] )
    121                     ) {
     119                    if ( array_key_exists( $m_key, $obj ) && ( $m_value == $obj[ $m_key ] ) ) {
    122120                        $matched++;
    123121                    }
    124122                } elseif ( is_object( $obj ) ) {
    125123                    // Treat object as an object.
    126                     if ( isset( $obj->{$m_key} )
    127                         && ( (string) $m_value === (string) $obj->{$m_key} )
    128                     ) {
     124                    if ( isset( $obj->{$m_key} ) && ( $m_value == $obj->{$m_key} ) ) {
    129125                        $matched++;
    130126                    }
     
    281277            }
    282278
    283             if ( (string) $a[ $field ] === (string) $b[ $field ] ) {
     279            if ( $a[ $field ] == $b[ $field ] ) {
    284280                continue;
    285281            }
Note: See TracChangeset for help on using the changeset viewer.