Skip to content

Commit 92710e7

Browse files
Apply suggestions from code review
Co-authored-by: Weston Ruter <[email protected]>
1 parent aa25519 commit 92710e7

2 files changed

Lines changed: 10 additions & 12 deletions

File tree

src/wp-includes/general-template.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4672,8 +4672,8 @@ function paginate_links( $args = '' ) {
46724672
/*
46734673
* Ensures sites not using trailing slashes get links in the form
46744674
* `/page/2` rather than `/page/2/`. On these sites, linking to the
4675-
* URL with a trailing slash will results in a 301 redirect from the
4676-
* incorrect URL to the correctly formattted one. This presents an
4675+
* URL with a trailing slash will result in a 301 redirect from the
4676+
* incorrect URL to the correctly formatted one. This presents an
46774677
* unnecessary performance hit.
46784678
*/
46794679
if ( $wp_rewrite->using_permalinks() && ! $wp_rewrite->use_trailing_slashes ) {

tests/phpunit/tests/general/paginateLinks.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ public function test_permalinks_with_trailing_slash_produce_links_with_trailing_
435435
$found_links = 0;
436436
while ( $processor->next_tag( 'A' ) ) {
437437
++$found_links;
438-
$href = $processor->get_attribute( 'href' );
438+
$href = (string) $processor->get_attribute( 'href' );
439439
$this->assertStringEndsWith( '/', $href, "Pagination links should end with a trailing slash, found: $href" );
440440
}
441441
$this->assertGreaterThan( 0, $found_links, 'There should be pagination links found.' );
@@ -459,8 +459,8 @@ public function test_permalinks_without_trailing_slash_produce_links_without_tra
459459
$found_links = 0;
460460
while ( $processor->next_tag( 'A' ) ) {
461461
++$found_links;
462-
$href = $processor->get_attribute( 'href' );
463-
$this->assertStringEndsNotWith( '/', $href, "Pagination links should end with a trailing slash, found: $href" );
462+
$href = (string) $processor->get_attribute( 'href' );
463+
$this->assertStringEndsNotWith( '/', $href, "Pagination links should not end with a trailing slash, found: $href" );
464464
}
465465
$this->assertGreaterThan( 0, $found_links, 'There should be pagination links found.' );
466466
}
@@ -474,7 +474,6 @@ public function test_permalinks_without_trailing_slash_produce_links_without_tra
474474
* @dataProvider data_query_strings
475475
*
476476
* @param string $query_string Query string.
477-
* @param string $unexpected Unexpected query string.
478477
*/
479478
public function test_permalinks_with_trailing_slash_do_not_modify_query_strings( string $query_string ) {
480479
update_option( 'posts_per_page', 2 );
@@ -489,7 +488,7 @@ public function test_permalinks_with_trailing_slash_do_not_modify_query_strings(
489488
$found_links = 0;
490489
while ( $processor->next_tag( 'A' ) ) {
491490
++$found_links;
492-
$href = $processor->get_attribute( 'href' );
491+
$href = (string) $processor->get_attribute( 'href' );
493492
$this->assertStringEndsWith( "/?{$query_string}", $href, "Pagination links should not modify the query string, found: $href" );
494493
}
495494
$this->assertGreaterThan( 0, $found_links, 'There should be pagination links found.' );
@@ -504,7 +503,6 @@ public function test_permalinks_with_trailing_slash_do_not_modify_query_strings(
504503
* @dataProvider data_query_strings
505504
*
506505
* @param string $query_string Query string.
507-
* @param string $unexpected Unexpected query string.
508506
*/
509507
public function test_permalinks_without_trailing_slash_do_not_modify_query_strings( string $query_string ) {
510508
update_option( 'posts_per_page', 2 );
@@ -519,7 +517,7 @@ public function test_permalinks_without_trailing_slash_do_not_modify_query_strin
519517
$found_links = 0;
520518
while ( $processor->next_tag( 'A' ) ) {
521519
++$found_links;
522-
$href = $processor->get_attribute( 'href' );
520+
$href = (string) $processor->get_attribute( 'href' );
523521
$this->assertStringEndsWith( "?{$query_string}", $href, "Pagination links should not modify the query string, found: $href" );
524522
$this->assertStringEndsNotWith( "/?{$query_string}", $href, "Pagination links should not be slashed before the query string, found: $href" );
525523
}
@@ -531,12 +529,12 @@ public function test_permalinks_without_trailing_slash_do_not_modify_query_strin
531529
* - test_permalinks_without_trailing_slash_do_not_modify_query_strings
532530
* - test_permalinks_with_trailing_slash_do_not_modify_query_strings
533531
*
534-
* @return array<string[]> Data provider.
532+
* @return array<string, array{ 0: string }> Data provider.
535533
*/
536534
public function data_query_strings(): array {
537535
return array(
538-
array( 'foo=bar' ),
539-
array( 'foo=bar&pen=pencil' ),
536+
'single query var' => array( 'foo=bar' ),
537+
'multi query vars' => array( 'foo=bar&pen=pencil' ),
540538
);
541539
}
542540
}

0 commit comments

Comments
 (0)