[wp-trac] [WordPress Trac] #64635: IXR_Client: Undefined array key "host" when parse_url returns no host
WordPress Trac
noreply at wordpress.org
Thu Feb 12 23:09:21 UTC 2026
#64635: IXR_Client: Undefined array key "host" when parse_url returns no host
--------------------------+-----------------------------
Reporter: bluefuton | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: XML-RPC | Version: trunk
Severity: trivial | Keywords:
Focuses: |
--------------------------+-----------------------------
`IXR_Client::__construct()` in `wp-includes/IXR/class-IXR-client.php`
accesses `$bits['host']` on line 33 without a key existence check after
calling `parse_url()`. This triggers an "Undefined array key" warning when
the URL passed has no host (e.g. a relative path like `/xmlrpc.php`).
Lines 34-35 already guard against missing keys for `port` and `path`:
{{{#!php
$bits = parse_url($server);
$this->server = $bits['host']; // <- unguarded
$this->port = $bits['port'] ?? 80;
$this->path = $bits['path'] ?? '/';
}}}
To improve resilience, we could apply the same pattern to `host`:
{{{#!php
$this->server = $bits['host'] ?? '';
}}}
'''How to reproduce:''' Pass a relative URL (no scheme/host) as the
`$server` parameter to `IXR_Client` with `$path = false`. For example,
this occurs in Jetpack when `Jetpack_IXR_Client` constructs an
`IXR_Client` and `JETPACK__API_BASE` is undefined.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64635>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list