#192 - Fix CommandRunnerTask options handling - #193
Merged
Merged
Conversation
The whole task options array was passed to Process::setOptions(), which only accepts blocking_pipes, create_process_group and create_new_console: every execution failed with 'Invalid option "cwd"'. A string commandline, although allowed, also failed with a TypeError. - Pass only the `options` option to Process::setOptions() - Run string commandlines through Process::fromShellCommandline() - Validate cwd, env, timeout and options types - Update the reference documentation, add unit tests Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.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.
Description
CommandRunnerTaskcould not be used at all: every execution failed.Process::setOptions(). That method only acceptsblocking_pipes,create_process_groupandcreate_new_console, so every run threwLogicException: Invalid option "cwd" passed to "Symfony\Component\Process\Process::setOptions()".commandlineis allowed by the options resolver, butnew Process()only accepts an array. It threw aTypeError.This PR:
optionsoption toProcess::setOptions(), and only when it is set;Process::fromShellCommandline(), so pipes and environment variables work ('grep "$PATTERN" | wc -l');cwd(null|string),env(null|array),timeout(null|int|float) andoptions(null|array), so a wrong value is reported when options are resolved instead of failing inside Symfony Process;docs/reference/tasks/command_runner_task.md) and links it fromdocs/index.md.Tested with 7 new unit tests (array and string commandlines, stdin input,
cwd/env, process options, invalid option type, failing command). They all fail onmainand pass with this fix. The full suite, PHPStan and PHP-CS-Fixer pass. Also checked end to end in a Symfony 7.4 app.Requirements
Breaking changes
None. Every configuration of this task failed before this change, so no working setup can break. The new type validation only rejects values that already crashed.