[wp-trac] [WordPress Trac] #63316: [E_WARNING] Undefined array key "host" in wp-includes/canonical.php on line 717
WordPress Trac
noreply at wordpress.org
Wed Jul 23 17:19:54 UTC 2025
#63316: [E_WARNING] Undefined array key "host" in wp-includes/canonical.php on line
717
-------------------------------------------------+-------------------------
Reporter: ArtZ91 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting
| Review
Component: Canonical | Version: 2.3
Severity: minor | Resolution:
Keywords: has-test-info has-patch dev- | Focuses:
feedback |
-------------------------------------------------+-------------------------
Comment (by johnjamesjacoby):
I have a few concerns about this patch:
1.
{{{
|| ! isset( $original['host'] )
}}}
I totally see how it makes sense to not attempt to redirect if
`$original['host']` is missing, but I found contrary evidence this use-
case is/was intended to be supported via #6890.
If `$original['host']` ''really'' is allowed to be empty, we'll need to
make sure it's set like we do for `path` & `query`.
2.
{{{
|| ! isset( $original['path'] )
}}}
Will break for valid & well-formed URLs like: `https://example.com?p=100`
`parse_url()` will not set the `path` key, but `query` (`p=100`) is still
deserving of canonical redirection.
----
What if we add...
{{{
if ( ! isset( $redirect['host'] ) ) {
$redirect['host'] = '';
}
}}}
...below...
{{{
// Notice fixing.
}}}
...and then let it do what it normally would to figure things out?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63316#comment:22>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list