Skip to content

Conversation

@Harshad071
Copy link

Summary

This pull request fixes the issue where wp cli update fails when the PHP binary path contains spaces.

Changes Made

  • Updated php/commands/src/CLI_Command.php to wrap PHP binary path with escapeshellarg().
  • This ensures that paths with spaces are correctly handled when spawning processes.

Issue

Resolves: #5815

Testing

  • Verified that wp cli update works with PHP binaries located in paths containing spaces.
  • No other commands affected.

@Harshad071 Harshad071 requested a review from a team as a code owner January 10, 2026 12:07
@github-actions
Copy link

Hello! 👋

Thanks for opening this pull request! Please check out our contributing guidelines. We appreciate you taking the initiative to contribute to this project.

Contributing isn't limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Harshad071, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the reliability of the wp cli update command by implementing a more robust method for handling PHP binary paths. By properly escaping paths that contain spaces, it ensures that the update process executes successfully across a wider range of system configurations, preventing failures due to path parsing issues.

Highlights

  • Fix for PHP binary paths with spaces: This pull request resolves an issue where the wp cli update command would fail if the PHP binary path contained spaces.
  • Improved path handling: The fix involves wrapping the PHP binary path with WP_CLI\Utils\esc_cmd('%s', ...) which internally uses escapeshellarg() to correctly handle paths containing spaces when spawning processes.
  • Issue Resolution: This change directly addresses and resolves issue Update command doesn't escape php_binary path, update fails when path has spaces #5815, improving the robustness of WP-CLI updates.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses an issue where wp cli update fails if the PHP binary path contains spaces. The fix involves escaping the binary path using WP_CLI\Utils\esc_cmd, which is a correct approach. However, the same issue exists for the temporary file path, which is also used in the command and is not escaped. My review includes a suggestion to also escape the temporary file path to make the fix comprehensive and prevent similar failures.

@codecov
Copy link

codecov bot commented Jan 10, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.

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

📢 Thoughts on this report? Let us know!

@Harshad071
Copy link
Author

Thanks for the Codecov report.
The lines flagged here involve spawning a process with escaped PHP binary and temporary file paths.
This behavior is platform-dependent and difficult to reliably cover in unit tests without tightly coupling to OS-level path handling.

I’ve manually verified the fix on a system where the PHP binary path contains spaces, and the update command works as expected.
I’m happy to add coverage if there’s a preferred approach for testing this scenario.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

1 participant