Handle page= and feed= query strings in redirect_guess_404_permalink(). fixes #20387

git-svn-id: http://svn.automattic.com/wordpress/trunk@20398 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
markjaquith 2012-04-07 05:39:08 +00:00
parent 5ccce3d681
commit 170ce91194

View File

@ -101,7 +101,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
if ( ! $redirect_url ) { if ( ! $redirect_url ) {
if ( $redirect_url = redirect_guess_404_permalink( $requested_url ) ) { if ( $redirect_url = redirect_guess_404_permalink( $requested_url ) ) {
$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url ); $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 );
} }
} }
@ -489,6 +489,11 @@ function redirect_guess_404_permalink( $current_url = '' ) {
$post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE $where AND post_status = 'publish'"); $post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE $where AND post_status = 'publish'");
if ( ! $post_id ) if ( ! $post_id )
return false; return false;
if ( get_query_var( 'feed' ) )
return get_post_comments_feed_link( $post_id, get_query_var( 'feed' ) );
elseif ( get_query_var( 'page' ) )
return trailingslashit( get_permalink( $post_id ) ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' );
else
return get_permalink( $post_id ); return get_permalink( $post_id );
} }