The MU forums have moved to WordPress.org

No trailing slash/posts_nav_link possible bug fix (6 posts)

  1. mediafetish
    Member
    Posted 16 years ago #

    We were experiencing a problem where if you visit one of our wpmu 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 on line 435 find (wpmu 1.2.1 - not sure about other versions):


    $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 and caused some funkiness.

    Not sure if this qualifies as a bug or a quick how-to for people experiencing the same problem as us - just wanted to share in case anyone else is trying to figure it out.

  2. drmike
    Member
    Posted 16 years ago #

    Best bet would be to submit this to trac so that the developers can look at it. I'm suggesting that you submit this via the regular wordpress trac as this code is lifted from that codebase and is not original to wpmu. It's line 477 currently in the development version.

    Usually when we see the issue, it;s due to the admin using an addon domain instead of running mu as a seperate domain.

    Thanks,
    -drmike

  3. mediafetish
    Member
    Posted 16 years ago #

    Thanks for pointing me to trac - I've never submitted a bug before. Maybe I'll give it a shot.

  4. mediafetish
    Member
    Posted 16 years ago #

  5. drmike
    Member
    Posted 16 years ago #

    Not a problem. I understand how you wrote it up by the way. Very well done. I wish others would ask questions and follow up like that. :)

  6. dsader
    Member
    Posted 16 years ago #

    I've squashed this pesky one on my site my commenting out the entire line

    $home_root = trailingslashit($home_root);
    from link_template.php. With no side-effect.

    I tried the fix above, instead, but blog themes stopped loading in transit, (no right sidebar, no footer).

    This fix is no fix for me.

About this Topic

  • Started 16 years ago by mediafetish
  • Latest reply from dsader