Fix group alias execution on Windows by passing $env to proc_open_compat#6221
Fix group alias execution on Windows by passing $env to proc_open_compat#6221
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| $env = null; | ||
| $proc = Utils\proc_open_compat( $full_command, [ STDIN, STDOUT, STDERR ], $pipes, null, $env ); |
There was a problem hiding this comment.
Passing $env initialized to null into Utils\proc_open_compat() appears to be a no-op: proc_open_compat() already calls _proc_open_compat_win_env( $cmd, $env ) on Windows even when $env is omitted/defaults to null (php/utils.php:1831-1837). Also, the sequential branch below still uses the 3-arg call, so if the PR description’s root cause is accurate, group aliases would still fail when WP_CLI_ALIAS_GROUPS_PARALLEL is not set. Please either adjust the real root cause (e.g., command/env construction) or apply an effective fix consistently to both branches (and/or proc_open_compat() itself).
| $env = null; | |
| $proc = Utils\proc_open_compat( $full_command, [ STDIN, STDOUT, STDERR ], $pipes, null, $env ); | |
| $proc = Utils\proc_open_compat( $full_command, [ STDIN, STDOUT, STDERR ], $pipes ); |
|
Already addressed in #5689 |
Group aliases with SSH configurations fail on Windows with "ssh is not recognized as an internal or external command". Single aliases work correctly.
Root Cause
run_alias_group()spawns child processes with Unix-style environment variable syntax:Without the
$envparameter,proc_open_compat()cannot invoke_proc_open_compat_win_env()to extract and separate environment variables on Windows. Child processes fail to load the config file, breaking SSH alias resolution.Changes
php/WP_CLI/Runner.php
$env = nullbeforeproc_open_compat()call$envas 5th parameter to enable Windows environment variable extractionThe existing
_proc_open_compat_win_env()function extractsWP_CLI_CONFIG_PATH=/pathfrom the command string and populates$env['WP_CLI_CONFIG_PATH'], allowing Windows to properly set the environment for child processes.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
example.com/usr/bin/php php vendor/bin/phpunit --color=always --bootstrap ./vendor/wp-cli/wp-cli-tests/tests/bootstrap.php(dns block)nosuchhost_asdf_asdf_asdf.com/usr/bin/php php vendor/bin/phpunit --color=always --bootstrap ./vendor/wp-cli/wp-cli-tests/tests/bootstrap.php(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.