Make WordPress Core

Opened 13 years ago

Closed 11 years ago

#4229 closed defect (bug) (worksforme)

No trailing slash on root dir breaks posts_nav_link

Reported by: mediafetish Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.2.1
Component: General Keywords: posts_nav_link
Focuses: Cc:


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)

#1 @foolswisdom
13 years ago

  • Milestone set to 2.4
  • Version set to 2.2

Sounds similar to #1341.

In the future, please confirm problem in WordPress core version before submitted bug.

#2 @foolswisdom
13 years ago

  • Version 2.2 deleted

#3 @rob1n
13 years ago

  • Owner changed from anonymous to rob1n
  • Version set to 2.1.3

#4 @rob1n
13 years ago

  • Milestone 2.4 deleted
  • Resolution set to worksforme
  • Status changed from new to closed

#5 @scramsby
13 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!

#6 @Nazgul
13 years ago

  • Milestone set to 2.4 (future)

#7 @rob1n
13 years ago

  • Owner rob1n deleted
  • Status changed from reopened to new

#8 @Denis-de-Bernardy
11 years ago

  • Milestone 2.9 deleted
  • Resolution set to worksforme
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.