[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
Thu Jul 24 16:02:42 UTC 2025
#63316: [E_WARNING] Undefined array key "host" in wp-includes/canonical.php on line
717
-------------------------------------------------+-------------------------
Reporter: ArtZ91 | Owner:
| johnjamesjacoby
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 6.9
Component: Canonical | Version: 2.3
Severity: minor | Resolution:
Keywords: has-test-info has-patch dev- | Focuses:
feedback needs-unit-tests |
-------------------------------------------------+-------------------------
Comment (by SirLouen):
I've been doing some debugging, and I've located the issue of why there is
an empty `host`, but there is actually a `port`.
[https://github.com/SirLouen/wordpress-
develop/blob/6064ab4db18b7ddc0d6881fab246da2bcca7f846/src/wp-
includes/canonical.php#L737 Here], with my `curl --http1.0 -H 'Host:'
http://localhost:8889`
Redirect host localhost and port 8889, but original is port 8889, but host
is empty
It comes to [https://github.com/SirLouen/wordpress-
develop/blob/6064ab4db18b7ddc0d6881fab246da2bcca7f846/src/wp-
includes/canonical.php#L840 this line] with an empty host then. Even if we
remove the port, it will get redirected there with `:///` `requested_url`
(no scheme, no host, no port)
As I say, leaving the empty host dangling through the function is not
doing any good. Also, we can try to handle that `:///` (or `://:port/`)
somewhere in the middle of `redirect_canonical`.
I would simply short-circuit, as I said. An Empty host can't be done with
HTTP1.1+ and supporting HTTP1.0 doesn't make much sense in 2025.
In case we want to leave this as I proposed in my first patch.
But if we are willing to let it go through, I'm still trying to figure out
how to trigger this with a Unit Test.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63316#comment:27>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list