Skip to content

Handle spaces in PHP binary path for the wp cli update command#5855

Merged
swissspidy merged 8 commits into
wp-cli:mainfrom
bgturner:testing/cli-update
Jan 22, 2026
Merged

Handle spaces in PHP binary path for the wp cli update command#5855
swissspidy merged 8 commits into
wp-cli:mainfrom
bgturner:testing/cli-update

Conversation

@bgturner

@bgturner bgturner commented Nov 2, 2023

Copy link
Copy Markdown
Contributor

Summary

Updates the wp cli update command to correctly handle spaces within the path to the PHP binary.

Context

Within #5815 , one of the potential fixes was merged (#5818 ) and later reverted (Issue Comment Reverted commit: #5822 )

In the original issue, it was recommended to start testing this part of the code so here's a start!

Notes

I did run into some issues running this test locally, but it's passing here. Part of me wonders if the make-phar.php file is too specifically tied to building the phar within the context of a GH workflow?

Because the `wp cli update` command needs a Phar to work, trying to
mimic what the `wp-cli-bundle` repo does in their Behat steps:

- https://github.com/wp-cli/wp-cli-bundle/blob/2638a2601dcbedf7b6a905a57e8761946032505a/features/cli.feature#L31C7-L31C7

While running this locally (m1 Mac), I'm getting an error that looks
like maybe the various repos aren't wired up correctly so I wonder if
I'll get something different when running in GH workflow.
@bgturner bgturner marked this pull request as ready for review November 3, 2023 19:12
@bgturner bgturner requested a review from a team as a code owner November 3, 2023 19:12

@danielbachhuber danielbachhuber left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're landing code changes in addition to tests, can you make sure the pull request title and description communicate accordingly?

Comment thread php/commands/src/CLI_Command.php Outdated
Comment thread features/cli-update.feature Outdated
Then STDOUT should be:
"""
Success: WP-CLI is at the latest version.
"""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you think of a way to add a scenario covering how the current code breaks?

@bgturner bgturner changed the title Testing wp cli update command Handle spaces in PHP binary path for the wp cli update command Nov 7, 2023
@swissspidy swissspidy requested review from a team and schlessera May 12, 2025 12:06
@codecov

codecov Bot commented Dec 2, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
php/commands/src/CLI_Command.php 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the wp cli update command to properly handle spaces in the PHP binary path by using Utils\esc_cmd() to escape shell arguments, and adds test coverage for the CLI update functionality.

  • Replaces string interpolation with Utils\esc_cmd() to properly escape the PHP binary path, temp file path, and allow-root flag
  • Adds a new feature test file with scenarios for CLI update functionality

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
php/commands/src/CLI_Command.php Updates command construction to use Utils\esc_cmd() for proper shell escaping when verifying downloaded phar
features/cli-update.feature Adds test scenarios for CLI update command, including error handling and update workflow

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread php/commands/src/CLI_Command.php Outdated
Comment thread features/cli-update.feature Outdated
@github-actions github-actions Bot added command:cli Related to 'cli' command command:cli-update Related to 'cli update' command labels Dec 22, 2025
Comment thread features/cli-update.feature Outdated
@swissspidy swissspidy added this to the 3.0.0 milestone Jan 22, 2026
@swissspidy swissspidy merged commit 346d1f5 into wp-cli:main Jan 22, 2026
52 of 53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:cli Related to 'cli' command command:cli-update Related to 'cli update' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update command doesn't escape php_binary path, update fails when path has spaces

4 participants