-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Added support for PHP paths with spaces in Magento CLI #13340
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
Conversation
From the DevDocs, MacOs and Windows are not supported. I haven't seen any server with a space in the PHP_BINARY, I'll check internally to see if this is worth adding and report back. |
@@ -115,7 +115,7 @@ public function __construct( | |||
$this->userCollection = $userCollection; | |||
$this->locale = $locale; | |||
$this->functionCallPath = | |||
PHP_BINARY . ' -f ' . BP . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'magento '; | |||
'"' . PHP_BINARY . '"' . ' -f ' . BP . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'magento '; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incomplete and will break if the path has double quotes in it. We'll also need to use escapeshellcmd
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a much better alternative! escapeshellcmd
@PivitParkour94 while obviously it is technically possible, are you aware of ANY supported OS actually having such spaces by default? |
https://github.com/magento/magento2/search?q=php_binary&type=Code&utf8=✓ this is not the only occurrence and I doubt there is any real reason to complicate the code. @miguelbalparda described issue is a duplicate of #5258 (comment), as I don't see any new argumentation I would insist on rejecting this PR. |
@orlangur This may not be an issue with default setup, but I think skipping it completely would be an oversight, simply because it doesn't fall into the cookie cut PHP installation. There are multiple places that the PHP_BINARY constant is used, but the issue is in running As it is such a simple fix, I thought I'd add it into the core and that would be good (granted I haven't added the PHPUnit test fix... that's my bad) rather than having to create an entire module that adds this support, it would be nice to just have it in core. Of course it is your choice to make, Thanks for your time |
…everted to wrapping it in double quotes
is an understatement. We have supported and unsupported operating systems and this fix, while simple, seems to be for a system we don't support. We'll come back to this if anything changes in the future. Thanks! |
Support for PHP paths that include spaces in the Magento CLI
Description
Found that some Magento CLI commands (
bin/magento deploy:mode:set production
for example) caused another command to be run, which is all good and fine except because it is then executed at a low levelexec
function call, if the PHP_BINARY variable had a space in it, it would cause it to break.Originally solved it simply escaping all spaces in the final command string, but that's a terrible security principle, not to mention it causes any arguments to not be recognised.
End solution seems to be as simple as wrapping the
\Magento\Deploy\Model\Filesystem::$functionCallPath
in quotes.Note: If the current state of having M2 running on Windows is that it won't happen that's a real shame, but as far as I know you can have spaces in filepaths on OSX or *nix (you probably wouldn't, but it's at least possible)
Fixed Issues (if relevant)
Rather than creating an issue, I just solved it with a PR because it is so simple
Manual testing scenarios
bin/magento deploy:mode:set production -vvv
Contribution checklist