Make WordPress Core

Changeset 58389


Ignore:
Timestamp:
06/11/2024 12:36:13 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Administration: Remove redundant type casting in WP_List_Table::search_box().

Scalar values passed to esc_attr() are already converted internally to a string via both wp_check_invalid_utf8() and _wp_specialchars().

Includes adding @covers tags for unit tests.

Follow-up to [58379].

See #58379.

Location:
trunk
Files:
2 edited

Legend:

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

    r58379 r58389  
    391391                        if ( is_array( $_REQUEST['orderby'] ) ) {
    392392                                foreach ( $_REQUEST['orderby'] as $key => $value ) {
    393                                         /*
    394                                          * Orderby can be either an associative array or non-associative array.
    395                                          * In the latter case, this makes sure the key is a string before calling esc_attr().
    396                                          */
    397                                         $key = (string) $key;
    398393                                        echo '<input type="hidden" name="orderby[' . esc_attr( $key ) . ']" value="' . esc_attr( $value ) . '" />';
    399394                                }
  • trunk/tests/phpunit/tests/admin/wpListTable.php

    r58379 r58389  
    142142
    143143        /**
    144          * Tests the "get_views_links()" method.
     144         * Tests the `WP_List_Table::get_views_links()` method.
    145145         *
    146146         * @ticket 42066
     
    256256
    257257        /**
    258          * Tests that "get_views_links()" throws a _doing_it_wrong().
     258         * Tests that `WP_List_Table::get_views_links()` throws a `_doing_it_wrong()`.
    259259         *
    260260         * @ticket 42066
     
    524524
    525525        /**
    526          * Tests that "search_box()" works correctly with an orderby array with multiple values.
     526         * Tests that `WP_List_Table::search_box()` works correctly with an `orderby` array with multiple values.
    527527         *
    528528         * @ticket 59494
     529         *
     530         * @covers WP_List_Table::search_box()
    529531         */
    530532        public function test_search_box_working_with_array_of_orderby_multiple_values() {
     
    545547
    546548        /**
    547          * Tests that "search_box()" works correctly with an orderby array with a single value.
     549         * Tests that `WP_List_Table::search_box()` works correctly with an `orderby` array with a single value.
    548550         *
    549551         * @ticket 59494
     552         *
     553         * @covers WP_List_Table::search_box()
    550554         */
    551555        public function test_search_box_working_with_array_of_orderby_single_value() {
     
    564568
    565569        /**
    566          * Tests that "search_box()" works correctly with orderby set to a string.
     570         * Tests that `WP_List_Table::search_box()` works correctly with `orderby` set to a string.
    567571         *
    568572         * @ticket 59494
     573         *
     574         * @covers WP_List_Table::search_box()
    569575         */
    570576        public function test_search_box_works_with_orderby_string() {
Note: See TracChangeset for help on using the changeset viewer.