Make WordPress Core


Ignore:
Timestamp:
07/05/2023 10:44:20 AM (23 months ago)
Author:
SergeyBiryukov
Message:

General: Compare values as strings in WP_List_Util::filter() and ::sort_callback().

This aims to preserve backward compatibility for code relying on type juggling when using the wp_list_filter() function, e.g. comparing a numeric string to an integer.

Follow-up to [55908].

Props azaozz, jeremyfelt, david.binda.
See #57839.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/functions/wpListFilter.php

    r55562 r56137  
    211211                ),
    212212            ),
     213            'string to int comparison' => array(
     214                array(
     215                    (object) array(
     216                        'foo' => '1',
     217                    ),
     218                ),
     219                array( 'foo' => 1 ),
     220                'AND',
     221                array(
     222                    0 => (object) array(
     223                        'foo' => '1',
     224                    ),
     225                ),
     226            ),
    213227        );
    214228    }
Note: See TracChangeset for help on using the changeset viewer.