Fix misleading success message when version check API fails #303
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When
wp core check-updatecannot reach the version check API (e.g., proxy misconfiguration), it displays "Success: WordPress is at the latest version" instead of reporting the network failure. This masks connectivity issues and prevents users from diagnosing configuration problems.Changes
Error capture via
http_api_debughookcapture_version_check_error()method to interceptWP_Errorresponses from version check APIwp_version_check()throwsWarning on failure
check_update()to display warning with error details when HTTP request failsTest coverage
Fixes #163
Original prompt
This section details on the original issue you should resolve
<issue_title>when shell env includes https_proxy, wp core check-update fails without php-curl installed</issue_title>
<issue_description>## Bug Report
Describe the current, buggy behavior
wp-cli seems to honor http_proxy and/or https_proxy shell environment variables properly only when php-curl is installed, but when using the fallback fsockopen transport of Requests,
wp core check-updateandwp core download --forcefail in misleading fashion, leading to the possible mistaken conclusion that the current install is up to date.Here is a shell session on a host that must use a proxy to reach the public internet and that does not have php-curl installed:
Now let's try again after installing php-curl:
Steps to replicate
wp core check-updateandwp core download --forceon internal.example.orgDescribe what you would expect as the correct outcome
I would expect both
check-updateanddownload --forceto correctly identify the existence of a new minor or major version. Failing that, I would expect both to give a cogent error.Multiple possible approaches could be pursued, including tests both for the availability of curl and the presence of proxy environment variables, but the present defaults present an ugly tripping hazard.
Environment where this error occurs
Additional context
Similar error to wp-cli/checksum-command#93
</issue_description>
<agent_instructions>
Core_Command/wp core check-updateuseswp_version_checkto fetch updates fromhttps://api.wordpress.org/core/version-check/1.7/. However, that function will silently fail if a HTTP proxy is incorrectly configured and that API endpoint is unreachable, especial...✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.