[wp-trac] [WordPress Trac] #34353: redirect_canonical() – Undefined indexes 'host' and 'scheme'
WordPress Trac
noreply at wordpress.org
Thu Mar 1 00:00:30 UTC 2018
#34353: redirect_canonical() – Undefined indexes 'host' and 'scheme'
--------------------------+-----------------------------
Reporter: theamila | Owner:
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: Future Release
Component: Canonical | Version: 4.3.1
Severity: normal | Resolution:
Keywords: needs-patch | Focuses:
--------------------------+-----------------------------
Comment (by Andy Schmidt):
This bug is still littering the log files. Spent time tracking down the
cause and was going to report it, now realizing this is a known issue.
In my case, problem is that several times daily, redirect_canonical() is
called with $_SERVER['HOST'] empty and $_SERVER['URI'] = '/'.
As a result $original['host'] is never set and the code will eventually
fail starting at lines 461 - 463:
{{{#!php
<?php
if ( strtolower($original['host']) ==
strtolower($redirect['host']) ||
( strtolower($original['host']) != 'www.' .
strtolower($redirect['host']) && 'www.' . strtolower($original['host']) !=
strtolower($redirect['host']) ) )
$redirect['host'] = $original['host'];
}}}
It should be trivial to fix at lines 70-73, currently:
{{{#!php
<?php
$original = @parse_url($requested_url);
if ( false === $original ) { // <-- this line requires a fix!
return;
}
}}}
by simply validating that a 'host' was actually set, since the code does
expect one later:
{{{#!php
<?php
if ( false === $original or !isset( $original['host'] ) ) {
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34353#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list