Repository navigation
when shell env includes https_proxy, wp core check-update fails without php-curl installed #292
Description
Bug Report
- [✅] Yes, I reviewed the contribution guidelines.
- [✅] Yes, more specifically, I reviewed the guidelines on how to write clear bug reports.
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-updateandwp core download --forceon 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 #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
Activity
swissspidy commentedon Oct 29, 2025
This seems like a duplicate of wp-cli/wp-cli#3019.
The tl;dr of that conversation:
wp-cli.ymland theextra-phpconfigWe might want to document this in our handbook.
tarheelcoxn commentedon Oct 29, 2025
EDIT: this is still a tripping hazard. Not a dupe because the bug is that check-update wrongly reports the install is up-to-date!
It does not make sense to merge this into a closed issue. Is there an existing ticket to improve documentation on wp-cli.yml? I spent time looking for where/how proxy config is set, and multiple sources just pointed back to wp-config.php as being the place to handle that, which seems wrong/bad.
Further, if the will of the maintainers is to move in the direction of documentation, there also needs to be a fix that prevents check-update from wrongly reporting that an install is up to date. I seem to have failed to convey myself clearly: this command behaves inconsistently, and can lead a user to a mistaken conclusion about the status of an install. That, the confusion, is the core thing I would like to see fixed.
Now, would I like to see http_proxy and https_proxy honored regardless of the presence of php-curl? Yes! I understand if the maintainers do not want to go down that path, and I am not going to push for that outcome. I would like to make sure folks always get either a correct response or a hard and clear error when
wp core check-updateis called, however.tarheelcoxn commentedon Oct 29, 2025
So again, regardless of the outcome of this ticket, for anybody else reading this in the future: if you're seeing the output of
wp core check-updatereport that you're up to date, but that does not seem right: check to confirm that php-curl is installed. Likewise, if you're gettingError: RuntimeExceptionthat includes the stringstream_socket_client(): Unable to connectyou probably have Requests falling back to the fsockopen Transport instead of the more feature-complete php-curl, so confirm that you have php-curl.swissspidy commentedon Oct 29, 2025
Right, so this is two-fold:
wp_version_check()to check for updates. If that function fails to trigger an error due to network configuration right now, then that would need fixing in core.update_coretransient is empty (for example ifwp_version_checkfailed, we could potentially display a warning. That would help distinguish between actual up-to-date sites and missing updates due to network issues. Happy to accept a PR with some tests here if this route proves viable.http_proxyenv var, for example throughwp-cli.yml.wp-cli.ymlis documented in our handbook already. My suggestion was specifically to document how to do this configuration. You might be able to do something like this:This would configure the proxy for HTTP requests in core when using WP-CLI, similar to when you define this in
wp-config.php. The setup would be slightly more complex for modifying HTTP requests from WP-CLI itself.tarheelcoxn commentedon Nov 6, 2025
I seem to have a bit of a Catch-22, since as I set up a dev environment (necessarily in a space that will require http_proxy to reach the public internet), I get errors like the following when running
composer behat:On the theory that something is better than nothing, and that perhaps I can be pointed in the direction of a good-enough setup to make a useful test, I'm commenting here, but I cannot currently commit to a timeline for submitting a PR, and would welcome somebody else making such a commitment.
swissspidy commentedon Dec 3, 2025
No worries, thanks for looking into it. Let's see if we can use some HTTP mocks for these tests.
swissspidy commentedon Dec 3, 2025
It doesn't help that
wp_trigger_error, which is called bywp_version_checkonly prints a warning ifWP_DEBUGis true (--debugflag). So you might actually get a warning today when enabling debug mode.tarheelcoxn commentedon Feb 2, 2026
I independently reproduced and confirmed this issue, and tested PR #303.
Reproduction
Using a Lima VM (Ubuntu 24.04, PHP 8.3.6 with php-curl), I:
wp core check-updatecorrectly detected updates (6.4.7 minor, 6.9 major)api.wordpress.orgvia iptablesupdate_coretransientwp core check-updateResult (main branch):
As @swissspidy noted, using
--debugreveals the underlying error fromwp-includes/update.php, but users without--debugget no indication the check failed.PR #303 Testing
I tested PR #303 with the same network-blocked scenario:
Result (PR #303):
The fix correctly surfaces the error without requiring
--debug. Normal operation (network available) continues to work as expected.I used Claude to assist with setting up the test environment.
swissspidy commentedon May 25, 2026
For enabling the HTTP proxy configuration support in WP-CLI, @ekamran has kindly built and shared https://github.com/ekamran/wp-cli-http-proxy-command today. If you're interested, I recommend giving it a try and providing feedback.