Fix ssh option with docker scheme ignored when set at root of wp-cli.yml#6249
Open
Fix ssh option with docker scheme ignored when set at root of wp-cli.yml#6249
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
- Configurator.php: Allow root-level `ssh` key to apply as default for aliased commands by excluding it from the alias-spec skip in merge_yml() - Runner.php: Add WP_CLI_SSH_RUN=1 env var to remote commands to prevent recursive SSH/docker calls when config file is mounted inside a container - Runner.php: Check WP_CLI_SSH_RUN in start() to skip config-based SSH when already inside an SSH/container session (CLI --ssh= still works) - flags.feature: Update existing SSH test assertions and add two new scenarios for root-level docker SSH config (with and without alias) Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix ssh option not accepting docker scheme in config file
Fix ssh option with docker scheme ignored when set at root of wp-cli.yml
Feb 25, 2026
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
For the docker-compose-run scheme, $wp_command was overwritten with
implode(' ', $wp_args), dropping $env_vars. Since docker compose run
doesn't invoke a shell, env var assignment prefix syntax doesn't work.
Instead, pass WP_CLI_SSH_RUN=1 (and WP_CLI_STRICT_ARGS_MODE=1 if set)
via -e flags on the `docker compose run` command itself.
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
Since run_ssh_command() now prepends WP_CLI_SSH_RUN=1 to the remote command, update five assertions in aliases.feature that check the exact SSH debug output to include WP_CLI_SSH_RUN=1: - Vagrant SSH test: 'wp --debug --version' → 'WP_CLI_SSH_RUN=1 wp ...' - Double-escape test: '; wp plugin list' → '; WP_CLI_SSH_RUN=1 wp ...' - Space-escape test: '; wp post create' → '; WP_CLI_SSH_RUN=1 wp ...' - Runtime alias tests (x2): 'env WP_CLI_RUNTIME_ALIAS= → 'WP_CLI_SSH_RUN=1 env WP_CLI_RUNTIME_ALIAS= Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
The two SSH args test scenarios were checking for 'wp at the end of the SSH command string, but now the command includes WP_CLI_SSH_RUN=1 before wp. Update the assertions to match. Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
swissspidy
reviewed
Mar 17, 2026
The format string for docker-compose-run had 8 %s placeholders but 9 values were passed (added $env_flags without adding a corresponding placeholder). Add the missing %s to the format string. Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
💡 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.
Comment on lines
+835
to
+839
| $command = '%s run %s%s%s%s%s%s%s %s'; | ||
|
|
||
| $env_flags = '-e WP_CLI_SSH_RUN=1 '; | ||
| if ( getenv( 'WP_CLI_STRICT_ARGS_MODE' ) ) { | ||
| $env_flags .= '-e WP_CLI_STRICT_ARGS_MODE=1 '; |
Comment on lines
1556
to
+1560
| if ( $this->config['ssh'] ) { | ||
| // @phpstan-ignore cast.string | ||
| $this->run_ssh_command( (string) $this->config['ssh'] ); | ||
| return; | ||
| // Don't recurse if SSH came from config file and we're already in an SSH/container session. | ||
| // Still allow SSH if it was explicitly passed via --ssh= on the CLI (present in runtime_config). | ||
| $ssh_from_cli = isset( $this->runtime_config['ssh'] ) && '' !== $this->runtime_config['ssh']; | ||
| if ( getenv( 'WP_CLI_SSH_RUN' ) && ! $ssh_from_cli ) { |
Comment on lines
834
to
+840
| if ( 'docker-compose-run' === $bits['scheme'] ) { | ||
| $command = '%s run %s%s%s%s%s%s %s'; | ||
| $command = '%s run %s%s%s%s%s%s%s %s'; | ||
|
|
||
| $env_flags = '-e WP_CLI_SSH_RUN=1 '; | ||
| if ( getenv( 'WP_CLI_STRICT_ARGS_MODE' ) ) { | ||
| $env_flags .= '-e WP_CLI_STRICT_ARGS_MODE=1 '; | ||
| } |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Configurator.php: allow root-levelsshto apply as default for aliased commandsRunner.php: addWP_CLI_SSH_RUN=1to env vars inrun_ssh_commandfor SSH/docker/docker-compose schemesRunner.php: propagateWP_CLI_SSH_RUN=1via-eflag fordocker-compose-runscheme ingenerate_ssh_command()Runner.php: checkWP_CLI_SSH_RUNinstart()to skip config-based ssh when already in an SSH/container sessionsshwith docker scheme (with and without alias)WP_CLI_SSH_RUN=1inflags.featureWP_CLI_SSH_RUN=1inaliases.feature(vagrant, double-escape, space-escape, runtime alias x2)Runner.php: sprintf placeholder count mismatch indocker-compose-runformat string (8 placeholders, 9 values)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.