-
Notifications
You must be signed in to change notification settings - Fork 3.3k
IXR: check if host key exists before accessing it in IXR_Client #10916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
IXR: check if host key exists before accessing it in IXR_Client #10916
Conversation
`parse_url()` does not always return a `host` key (e.g. for relative paths). Use the null coalescing operator to fall back to an empty string, consistent with how `port` and `path` are already handled. Adds a unit test to verify no error is triggered when the host is missing. Trac: https://core.trac.wordpress.org/ticket/64635
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Co-authored-by: Weston Ruter <westonruter@gmail.com>
|
Should the same fix be applied to wordpress-develop/src/wp-includes/class-wp-http-ixr-client.php Lines 26 to 29 in d3b793f
|
Summary
IXR_Clientaccesses$bits['host']fromparse_url()without checking if the key exists, which can trigger an undefined index warning for URLs without a host component (e.g. relative paths).??) to fall back to an empty string, consistent with howportandpathare already handled on the adjacent lines.Trac ticket
https://core.trac.wordpress.org/ticket/64635
Test plan
IXR_Clientno longer triggers an undefined index warning when instantiated with a URL lacking a host componentnpm run test:php -- --filter test_ixr_client_does_not_error_when_host_is_ missingand confirm the test passes