Ticket #16557: 16557.diff
File 16557.diff, 1.6 KB (added by , 9 years ago) |
---|
-
src/wp-includes/canonical.php
136 136 } 137 137 138 138 if ( ! $redirect_url ) { 139 if ( $redirect_url = redirect_guess_404_permalink() ) { 139 $redirect_url = apply_filters( '404_redirect', $redirect_url ); 140 if ( $redirect_url ) { 140 141 $redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'page', 'feed', 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url ); 141 142 } 142 143 } … … 553 554 return false; 554 555 } 555 556 557 add_filter( '404_redirect', 'redirect_guess_404_permalink' ); 558 556 559 add_action('template_redirect', 'redirect_canonical'); 557 560 558 561 function wp_redirect_admin_locations() { -
tests/phpunit/tests/canonical.php
280 280 // Todo: Endpoints (feeds, trackbacks, etc), More fuzzed mixed query variables, comment paging, Home page (Static) 281 281 ); 282 282 } 283 284 285 /** 286 * @ticket 16557 287 */ 288 public function test_guess_redirect() { 289 // Fake a 404 290 $GLOBALS[ 'wp_query' ]->is_404 = true; 291 292 // Fake a request to /child-page-1/ 293 set_query_var( 'name', 'child-page-1' ); 294 295 $test_url = '/child-page-1/'; 296 $expected = '/child-page-1/'; 297 298 remove_filter( '404_redirect', 'redirect_guess_404_permalink' ); 299 300 $this->test( $test_url, $expected, 16557 ); 301 302 } 303 283 304 }