[wp-trac] Re: [WordPress Trac] #5766: endless redirect loop
WordPress Trac
wp-trac at lists.automattic.com
Mon Feb 4 20:31:00 GMT 2008
#5766: endless redirect loop
-------------------------------------+--------------------------------------
Reporter: pixline | Owner: markjaquith
Type: defect | Status: new
Priority: normal | Milestone: 2.5
Component: General | Version: 2.3.2
Severity: normal | Resolution:
Keywords: has-patch needs-testing |
-------------------------------------+--------------------------------------
Comment (by jhodgdon):
Just a little more on this.
The problem that Pixline identified comes up in wp-includes/canonical.php,
where the function redirect_canonical gets called to turn a possibly
badly-formatted URL into a "canonical" URL. This function rewrites the URL
so that everything is "canonical".
The issue is that if you have a url like (site url)/page/2/(suffix), that
rewrite function screws it up, because the code that handles paging
tacitly assumes that the page section is at the end of the URL. The
offending line of code is here:
{{{
$paged_redirect['path'] =
preg_replace('|/page/[0-9]+?(/+)?$|', '/',
$paged_redirect['path']); // strip off any existing paging
}}}
The regex used on that line only strips off /page/N when it is at the end
of the URL, and then lower down in the function, it adds in /page/N at the
end of the URL, and you end up with a URL like (site
url)/page/2/(suffix)/page/2, which is no good at all.
At some point recently, when one of my Language Switcher users pointed out
that the URL suffixes my plugin was appending were doing this, I tried
patching it so that it would work with page/N not at the end of the URL,
but I ran into other problems, which I think had to do with rewrite rules
(even though I had rewrite rules in Language Switcher that would handle
pages not being at the end of the URL, something didn't work correctly).
My vague recollection was that fixing this issue at the WP level would
have involved a large patch, and waiting for a new version to come out, so
I elected to redo Language Switcher so that the URLs were in a more
"canonical" form (i.e. LS puts URLs into format lang/en/page/2 instead of
page/2/lang/en).
So my guess is that Pixline's patch might break something else, and
recommend it be tested extensively before committing it.
By the way, URLs like page/2/xyz/pdq used to work in older versions of
WordPress -- not sure which -- the change so they didn't work may have
been introduced in [5974], but I am not certain about that.
Pixline - contact me off-line (or download Language Switcher from
poplarware.com) if you want code samples. LS is GPL-licensed, so feel free
to reuse its URL rewriting mechanism.
--
Ticket URL: <http://trac.wordpress.org/ticket/5766#comment:6>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list