Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

bgturner
Copy link
Contributor

@bgturner bgturner commented Nov 2, 2023

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
Copy link
Member

@danielbachhuber danielbachhuber left a comment

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?

@@ -357,7 +357,7 @@ public function update( $_, $assoc_args ) {

$allow_root = WP_CLI::get_runner()->config['allow-root'] ? '--allow-root' : '';
$php_binary = Utils\get_php_binary();
$process = Process::create( "{$php_binary} $temp --info {$allow_root}" );
$process = Process::create( Utils\esc_cmd( '%s %s --info %s', $php_binary, $temp, $allow_root ) );
Copy link
Member

Choose a reason for hiding this comment

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

I think I'm rethinking my original suggestion to use Utils\esc_cmd(), as the originally proposed escapeshellarg( Utils\get_php_binary() ); covers less surface area.

Thoughts?

Then STDOUT should be:
"""
Success: WP-CLI is at the latest version.
"""
Copy link
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
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.

None yet

2 participants