Conversation
…odes. `download_url()` returned a `WP_Error` with the code `http_404` for every non-200 response, so a 403, 406 or 500 was indistinguishable from a real 404 without digging into the error data. The error code now reflects the actual status code (`http_403`, `http_500`, ...), matching how Site Health names the same kind of error. A response without a status code keeps `http_404`. Trac ticket: https://core.trac.wordpress.org/ticket/60564
|
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. |
Trac ticket: https://core.trac.wordpress.org/ticket/60564
download_url()returns aWP_Errorwith the codehttp_404for every non-200 response. A 403, 406 or 500 is indistinguishable from a real 404 unless the caller digs the status code out ofget_error_data().This PR names the error after the actual status code (
http_403,http_500, ...), the same convention Site Health already uses for its own HTTP errors ('http_' . wp_remote_retrieve_response_code()inclass-wp-site-health.php). It builds on #8187 by @Vedant-Gandhi and adds:http_404when the response carries no status code at all (wp_remote_retrieve_response_code()returns''for apre_http_requestshort-circuit without aresponsearray — the one-liner would have producedhttp_);@sincenote in the docblock;http_404cases.Backward compatibility: only callers comparing
get_error_code()against the literal'http_404'are affected, and for those the old code was wrong for every status but 404. Nothing in core does this; the error message andget_error_data()(code,body) are unchanged. Probably worth a line in the 7.2 misc dev note.