Opened 6 years ago
Closed 4 years ago
#4229 closed defect (bug) (worksforme)
No trailing slash on root dir breaks posts_nav_link
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | General | Version: | 2.2.1 |
| Severity: | normal | Keywords: | posts_nav_link |
| Cc: |
Description
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)
comment:1
foolswisdom
— 6 years ago
- Milestone set to 2.4
- Version set to 2.2
comment:2
foolswisdom
— 6 years ago
- Version 2.2 deleted
comment:4
rob1n
— 6 years ago
- Milestone 2.4 deleted
- Resolution set to worksforme
- Status changed from new to closed
comment:5
scramsby
— 6 years ago
- Resolution worksforme deleted
- Status changed from closed to reopened
- Version changed from 2.1.3 to 2.2.1
I've hit this problem as well in the latest version of WPMU. This isn't the same issue as #1341. The problem is completely solved by removing the "$home_root = trailingslashit($home_root);" line like originally stated in the bug. Please investigate and fix this in the WP source code so I don't have to re-enter this fix into our code base each time we update WPMU. Please let me know if you need help seeing this issue. Thanks!
comment:8
Denis-de-Bernardy
— 4 years ago
- Milestone 2.9 deleted
- Resolution set to worksforme
- Status changed from new to closed
Sounds similar to #1341.
In the future, please confirm problem in WordPress core version before submitted bug.