You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CommandRunnerTask always fails: all task options are passed to Process::setOptions() #192
$ bin/console cleverage:process:execute demo.command_runner
Starting process 'demo.command_runner'...
CRITICAL [cleverage_process_task] Invalid option "cwd" passed to "Symfony\Component\Process\Process::setOptions()".
Supported options are "blocking_pipes", "create_process_group", "create_new_console".
A string commandline (allowed by setAllowedTypes('commandline', ['string', 'array'])) fails even earlier:
Symfony\Component\Process\Process::__construct(): Argument #1 ($command) must be of type array, string given,
called in src/Task/Process/CommandRunnerTask.php on line 35
Tested on main (f8201fe), PHP 8.5, Symfony 7.4. CommandRunnerTask.php is unchanged on current main (e70a620).
$process->setOptions($options) receives the whole resolved options array (commandline, cwd, env, timeout, options). Process::setOptions() only accepts blocking_pipes, create_process_group and create_new_console. The intent was to pass the task's options option: $options['options'].
new Process() only accepts an array command. A string commandline must go through Process::fromShellCommandline().
The reference documentation added in #188 already describes the failure in its Notes section.
Proposed fix
pass only $options['options'] to Process::setOptions(), and only when it is not null;
use Process::fromShellCommandline() when commandline is a string;
validate the types of cwd, env, timeout and options;
update docs/reference/tasks/command_runner_task.md: remove the Notes section and document options.
Activity
cleverage#192 - Fix CommandRunnerTask options handling
Merge pull request #193 from cleverage/192