Changeset 61136
- Timestamp:
- 11/04/2025 06:29:36 PM (4 months ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
src/wp-includes/canonical.php (modified) (2 diffs)
-
tests/phpunit/includes/testcase-canonical.php (modified) (1 diff)
-
tests/phpunit/tests/canonical/noRewrite.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/canonical.php
r60496 r61136 78 78 } 79 79 80 // Notice fixing. 81 $original += array( 82 'host' => '', 83 'path' => '', 84 'query' => '', 85 'scheme' => '', 86 ); 87 80 88 $redirect = $original; 81 89 $redirect_url = false; 82 90 $redirect_obj = false; 83 84 // Notice fixing.85 if ( ! isset( $redirect['path'] ) ) {86 $redirect['path'] = '';87 }88 if ( ! isset( $redirect['query'] ) ) {89 $redirect['query'] = '';90 }91 91 92 92 /* … … 617 617 618 618 // Notice prevention after new parse_url( $redirect_url ) calls 619 if ( ! isset( $redirect['path'] ) ) {620 $redirect['path'] = '';621 }622 if ( ! isset( $redirect['query'] ) ) {623 $redirect['query'] = '';624 }619 $redirect += array( 620 'host' => '', 621 'path' => '', 622 'query' => '', 623 'scheme' => '', 624 ); 625 625 626 626 // Trailing /index.php. -
trunk/tests/phpunit/includes/testcase-canonical.php
r54865 r61136 346 346 */ 347 347 public function get_canonical( $test_url ) { 348 $test_url = home_url( $test_url ); 348 if ( isset( $_SERVER['HTTP_HOST'] ) ) { 349 $test_url = home_url( $test_url ); 350 } else { 351 $test_url = ''; 352 } 349 353 350 354 $can_url = redirect_canonical( $test_url, false ); -
trunk/tests/phpunit/tests/canonical/noRewrite.php
r52010 r61136 275 275 276 276 array( '/?comp=East+(North)', '/?comp=East+(North)', 49347 ), 277 278 array( null, '/', 63316 ), // No Path and Query 277 279 ); 278 280 } 281 282 /** 283 * Test the canonical URL when the host header is not set. 284 * 285 * @ticket 63316 286 * @dataProvider data_missing_host_header 287 * @param string $wp_home The WP_HOME value to set. 288 * @param string $expected_url The expected canonical URL. 289 */ 290 public function test_missing_host_header( $wp_home, $expected_url ) { 291 $_SERVER['HTTP_HOST'] = null; 292 add_filter( 293 'pre_option_home', 294 static function () use ( $wp_home ) { 295 return $wp_home; 296 } 297 ); 298 $this->assertCanonical( '/', $expected_url, 63316 ); 299 } 300 301 /** 302 * Data provider for test_missing_host_header(). 303 * 304 * @return array[] 305 */ 306 public function data_missing_host_header() { 307 return array( 308 'no port' => array( 309 'wp_home' => 'http://example.com', 310 'expected_url' => ':///', 311 ), 312 'with port' => array( 313 'wp_home' => 'http://example.com:8889', 314 'expected_url' => '://:8889/', 315 ), 316 ); 317 } 279 318 }
Note: See TracChangeset
for help on using the changeset viewer.