[wp-trac] [WordPress Trac] #36873: Canonical redirect code does opposite of comment, breaks script when home_url starts with https
WordPress Trac
noreply at wordpress.org
Wed May 18 03:43:03 UTC 2016
#36873: Canonical redirect code does opposite of comment, breaks script when
home_url starts with https
--------------------------+-----------------------------
Reporter: thasmin | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Canonical | Version: 4.5.2
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
The comment on line 444 in wp-includes/canonical.php says that it only
changes the host if it's adding or removing "www.". It changes the host to
lowercase if capitalization is the only difference or if the change is NOT
adding or removing "www.". Either the comment or the code should be
changed.
This is causing a problem when I try to run the script below. If the home
url (used on line 176) is "https://www.example.com/", then the host is
removed and redirect url changes to "https:///". This makes the parse_url
call on line 69 return false and end processing.
I believe this is why the script fails. There's a lot of code here.
Apologies if I have it wrong.
Here's the script:
define('WP_USE_THEMES', true);
require_once('/var/www/html/wp-blog-header.php');
I can workaround the bug by explicitly setting some server variables
before calling that code:
$_SERVER = array (
'REQUEST_URI' => '/',
'HTTPS' => 'on',
'HTTP_HOST' => 'www.example.com',
);
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36873>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list