Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 3, 2025

When wp core check-update cannot 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_debug hook

  • Added capture_version_check_error() method to intercept WP_Error responses from version check API
  • Filters by URL and response context to capture only relevant errors
  • Uses try-finally to ensure hook cleanup even if wp_version_check() throws

Warning on failure

  • Modified check_update() to display warning with error details when HTTP request fails
  • Success message now only appears when update check succeeds and installation is current

Test coverage

  • Added Behat scenario mocking failed API response to verify warning behavior
// Before: Misleading message on network failure
$ wp core check-update
Success: WordPress is at the latest version.

// After: Clear error indication
$ wp core check-update  
Warning: Failed to check for updates: stream_socket_client(): Unable to connect to ssl://api.wordpress.org:443 (Connection timed out)

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-update and wp core download --force fail 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:

$ curl -s https://api.wordpress.org/core/version-check/1.7/?locale=en_US | jq . |head -n 20
{
  "offers": [
    {
      "response": "upgrade",
      "download": "https://downloads.wordpress.org/release/wordpress-6.8.3.zip",
      "locale": "en_US",
      "packages": {
        "full": "https://downloads.wordpress.org/release/wordpress-6.8.3.zip",
        "no_content": "https://downloads.wordpress.org/release/wordpress-6.8.3-no-content.zip",
        "new_bundled": "https://downloads.wordpress.org/release/wordpress-6.8.3-new-bundled.zip",
        "partial": false,
        "rollback": false
      },
      "current": "6.8.3",
      "version": "6.8.3",
      "php_version": "7.2.24",
      "mysql_version": "5.5.5",
      "new_bundled": "6.7",
      "partial_version": false
    },
$ wp core version
6.8.2
$ wp core check-update
Success: WordPress is at the latest version.
$ wp core download --force
Error: RuntimeException: Failed to get url 'https://api.wordpress.org/core/version-check/1.7/?locale=en_US': stream_socket_client(): Unable to connect to ssl://api.wordpress.org:443 (Connection timed out).

Now let's try again after installing php-curl:

$ dpkg -l |grep "php.*curl"
ii  php8.2-curl                                8.2.29-1~deb12u1                        amd64        CURL module for PHP
$ wp core check-update
+---------+-------------+-----------------------------------------------------------------------+
| version | update_type | package_url                                                           |
+---------+-------------+-----------------------------------------------------------------------+
| 6.8.3   | minor       | https://downloads.wordpress.org/release/wordpress-6.8.3-partial-2.zip |
+---------+-------------+-----------------------------------------------------------------------+

Steps to replicate

  • Create a container or VM (let's call it internal.example.org) that must use a proxy of the form http://proxy.example.org:3128 to reach the public Internet.
  • Confirm access to public resources, specifically the URL https://api.wordpress.org/core/version-check/1.7/?locale=en_US with a tool such as curl.
  • install the most recent vulnerable version of wordpress on internal.example.org
  • confirm WP install is reachable locally
  • attempt both wp core check-update and wp core download --force on internal.example.org

Describe what you would expect as the correct outcome

I would expect both check-update and download --force to 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

$ wp --info
OS:     Linux 6.1.0-40-amd64 wp-cli/core-command#1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
Shell:  /bin/bash
PHP binary:     /usr/bin/php8.2
PHP version:    8.2.29
php.ini used:   /etc/php/8.2/cli/php.ini
MySQL binary:   /usr/bin/mariadb
MySQL version:  mariadb  Ver 15.1 Distrib 10.11.14-MariaDB, for debian-linux-gnu (x86_64) using  EditLine wrapper
SQL modes:
WP-CLI root dir:        phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      phar://wp-cli.phar/vendor
WP_CLI phar path:       phar:///usr/local/bin/wp
WP-CLI packages dir:
WP-CLI cache dir:       /localhome/phptest/.wp-cli/cache
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.12.0

Additional context

Similar error to wp-cli/checksum-command#93

</issue_description>

<agent_instructions>Core_Command / wp core check-update uses wp_version_check to fetch updates from https://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.

Copilot AI changed the title [WIP] Fix wp core check-update failure with https_proxy Fix misleading success message when version check API fails Dec 3, 2025
Copilot AI requested a review from swissspidy December 3, 2025 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

when shell env includes https_proxy, wp core check-update fails without php-curl installed

2 participants