No trailing slash on root dir breaks posts_nav_link
|Reported by:||mediafetish||Owned by:|
I've never submitted a bug so bear with me - I did a search prior to submitting and couldn't find this...
Found this in wpmu but the source came from wp - we had a problem where if you visit one of our blogs without the trailing slash - (blogs.example.com/subblog) the the paging features of posts_nav_link would produce funky links like blogs.example.com/subblog/subblog/page/2/ (notice the doubled 'subblog')
Some digging led to:
In link-template.php find (wpmu 1.2.1 - not sure about other versions or wp):
$home_root = trailingslashit($home_root);
and change it to
$home_root = untrailingslashit($home_root);
Doing this made it so that this block:
$home_root = parse_url(get_option('home')); $home_root = $home_root['path']; $home_root = untrailingslashit($home_root); $qstr = preg_replace('|^'. $home_root . '|', '', $qstr); $qstr = preg_replace('|^/+|', '', $qstr);
sets the value of $qstr to the same thing regardless of whether the path in the browser ends with a slash or not.
The old way (with 'trailingslashit') would try to match home_root (blogs.example.com/subblog/) against the path in the browser (blogs.example.com/subblog) which doesn't match.
Change History (8)
- Milestone 2.4 deleted
- Resolution set to worksforme
- Status changed from new to closed
- Resolution worksforme deleted
- Status changed from closed to reopened
- Version changed from 2.1.3 to 2.2.1