[wp-trac] [WordPress Trac] #21602: redirect_canonical can lead to infinite loop on index navigation if site url is not all lower case
WordPress Trac
wp-trac at lists.automattic.com
Mon Aug 27 21:37:07 UTC 2012
#21602: redirect_canonical can lead to infinite loop on index navigation if site
url is not all lower case
--------------------------+------------------------------
Reporter: sreedoap | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Canonical | Version:
Severity: normal | Resolution:
Keywords: has-patch |
--------------------------+------------------------------
Comment (by nacin):
Confirmed.
All that is necessary is this:
{{{
add_action( 'wp', function() {
is_front_page();
});
}}}
This is a tricky one.
I haven't tracked down what exactly fails to trigger an infinite redirect,
but I do know why is_front_page() is the trigger. In canonical, there is
this conditional:
{{{
} elseif ( is_page() && !is_feed() && isset($wp_query->queried_object) &&
'page' == get_option('show_on_front') && $wp_query->queried_object->ID ==
get_option('page_on_front') && ! $redirect_url ) {
$redirect_url = home_url('/');
}}}
This is designed to redirect a /front-page/ page that is assigned to the
page_on_front to home_url(). But, since it checks if
$wp_query->queried_object is set, it doesn't actually work.
is_front_page() calls is_page() with the right arguments to trigger a
proper get_queried_object(). This then causes the conditional to run.
As to why it spirals into a redirect loop, home_url() returns something
different than what was submitted, and all that jazz.
I see the need for multiple unit tests here, both to cover front-page -> /
redirect failures, and the domain issue.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/21602#comment:7>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list