﻿id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc
18318,Slug changes for pages do not redirect (like posts do),varun21,,"Alert: Newbie trac user :). Already tried searching for existing bugs

Steps to reproduce this issue:
1. Publish a page.
2. disable canonical redirects. Pretty permalinks enabled. Clean install of WP with no plugins.
3. Change the page slug
4. Old slug does not redirect to the new slug (only when post_type is page).

Code suspected to be the cause:
/wp-includes/query.php
function wp_old_slug_redirect
line 3488: 
{{{
//Guess the current post_type based on the query vars

		if ( get_query_var('post_type') )
			$post_type = get_query_var('post_type');
		elseif ( !empty($wp_query->query_vars['pagename']) )
			$post_type = 'page';
		else
			$post_type = 'post';
}}}

The trouble is pagename in $wp_query->query_vars['pagename'] is never set/found, so the guess for post_type always guesses the post_type as a 'post'. Thus when a page redirect is expected, the query doesn't fetch any results.

example query vars for post expecting redirection
{{{
Array ( [page] => 0 [name] => sample-post-with-threaded-comments [error] => [m] => 0 [p] => 0 [post_parent] => [subpost] => [subpost_id] => [attachment] => [attachment_id] => 0 [static] => [pagename] => [page_id] => 0 [second] => [minute] => [hour] => [day] => 0 [monthnum] => 0 [year] => 0 [w] => 0 [category_name] => [tag] => [cat] => [tag_id] => [author_name] => [feed] => [tb] => [paged] => 0 [comments_popup] => [meta_key] => [meta_value] => [preview] => [s] => [sentence] => [fields] => [category__in] => Array ( ) [category__not_in] => Array ( ) [category__and] => Array ( ) [post__in] => Array ( ) [post__not_in] => Array ( ) [tag__in] => Array ( ) [tag__not_in] => Array ( ) [tag__and] => Array ( ) [tag_slug__in] => Array ( ) [tag_slug__and] => Array ( ) [ignore_sticky_posts] => [suppress_filters] => [cache_results] => 1 [update_post_term_cache] => 1 [update_post_meta_cache] => 1 [post_type] => [posts_per_page] => 10 [nopaging] => [comments_per_page] => 50 [no_found_rows] => [order] => DESC ) 

example query vars for page expecting redirection
Array ( [page] => 0 [name] => sumedh [error] => [m] => 0 [p] => 0 [post_parent] => [subpost] => [subpost_id] => [attachment] => [attachment_id] => 0 [static] => [pagename] => [page_id] => 0 [second] => [minute] => [hour] => [day] => 0 [monthnum] => 0 [year] => 0 [w] => 0 [category_name] => [tag] => [cat] => [tag_id] => [author_name] => [feed] => [tb] => [paged] => 0 [comments_popup] => [meta_key] => [meta_value] => [preview] => [s] => [sentence] => [fields] => [category__in] => Array ( ) [category__not_in] => Array ( ) [category__and] => Array ( ) [post__in] => Array ( ) [post__not_in] => Array ( ) [tag__in] => Array ( ) [tag__not_in] => Array ( ) [tag__and] => Array ( ) [tag_slug__in] => Array ( ) [tag_slug__and] => Array ( ) [ignore_sticky_posts] => [suppress_filters] => [cache_results] => 1 [update_post_term_cache] => 1 [update_post_meta_cache] => 1 [post_type] => [posts_per_page] => 10 [nopaging] => [comments_per_page] => 50 [no_found_rows] => [order] => DESC ) 
}}}",defect (bug),closed,normal,,Canonical,3.2.1,normal,duplicate,needs-patch,varun21@…
