Forums

[resolved] Case-sensitive comparison in WP core causes blank URL requests to fail. (2 posts)

  1. jayhealey
    Member
    Posted 3 months ago #

    Hi,

    I recently setup a site on WordPress 3.3.1, on IIS7 using PHP 5.3. I setup standard pages and blog rolls and wanted the homepage to redirect to one of the pages. This worked succesfully on a development server, but when I promoted to it to a live server (similar setup) the homepage was displaying the 404 page.

    Having dug into the core, I found the issue was down to the following line of code not comparing properley:

    /wp-includes/class-wp.php, line 181:

    // If the request uri is the index, blank it out so that we don't try to match it against a rule.
        if ( $req_uri == $wp_rewrite->index )
            $req_uri = '';

    After a bit of digging around, the '$req_uri' was set to 'Index.php' and '$wp_rewrite->index' was set to 'index.php'.

    So, this comparison failed to occur so the final $wp_query was querying data with a request of 'Index.php'.

    My fix was to alter this comparison to ensure the string was completely equal, making sure case was no longer an issue:

    // If the request uri is the index, blank it out so that we don't try to match it against a rule.
        if (strcmp(strtolower($req_uri), strtolower($wp_rewrite->index)) == 0)
            $req_uri = '';

    This resolved the issue. I just wanted to report this, maybe it can be fixed and put into the core - if so, how do I go about promoting that?

    Thanks.

  2. fonglh
    Member
    Posted 3 months ago #

    Start a new ticket in trac. You can submit your patch there too.

    http://core.trac.wordpress.org/

Reply

You must log in to post.

About this Topic