Skip to content

Commit adeb3ec

Browse files
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. git-svn-id: https://develop.svn.wordpress.org/trunk@58389 602fd350-edb4-49c9-b593-d223f7449a82
1 parent b215c59 commit adeb3ec

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/wp-admin/includes/class-wp-list-table.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -390,11 +390,6 @@ public function search_box( $text, $input_id ) {
390390
if ( ! empty( $_REQUEST['orderby'] ) ) {
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
}
400395
} else {

tests/phpunit/tests/admin/wpListTable.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function data_should_only_add_primary_column_when_needed() {
141141
}
142142

143143
/**
144-
* Tests the "get_views_links()" method.
144+
* Tests the `WP_List_Table::get_views_links()` method.
145145
*
146146
* @ticket 42066
147147
*
@@ -255,7 +255,7 @@ public function data_get_views_links() {
255255
}
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
261261
*
@@ -523,9 +523,11 @@ public function data_compat_fields() {
523523
}
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() {
531533
$_REQUEST['s'] = 'search term';
@@ -544,9 +546,11 @@ public function test_search_box_working_with_array_of_orderby_multiple_values()
544546
}
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() {
552556
// Test with one 'orderby' element.
@@ -563,9 +567,11 @@ public function test_search_box_working_with_array_of_orderby_single_value() {
563567
}
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() {
571577
// Test with one 'orderby' element.

0 commit comments

Comments
 (0)