Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e13bf4e

Browse files
ausinicolas-grekas
authored andcommitted
[Process] Fix backwards compatibility for invalid commands
1 parent 586f459 commit e13bf4e

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/Symfony/Component/Process/Process.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,11 @@ public function start(?callable $callback = null, array $env = []): void
358358

359359
try {
360360
$process = @proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options);
361+
362+
// Ensure array vs string commands behave the same
363+
if (!$process && \is_array($commandline)) {
364+
$process = @proc_open('exec '.$this->buildShellCommandline($commandline), $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options);
365+
}
361366
} finally {
362367
if ($this->ignoredSignals && \function_exists('pcntl_sigprocmask')) {
363368
// we restore the signal mask here to avoid any side effects

src/Symfony/Component/Process/Tests/ProcessTest.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,8 @@ public function testInvalidCwd()
7272
*/
7373
public function testInvalidCommand(Process $process)
7474
{
75-
try {
76-
$this->assertSame('\\' === \DIRECTORY_SEPARATOR ? 1 : 127, $process->run());
77-
} catch (ProcessStartFailedException $e) {
78-
// An invalid command might already fail during start since PHP 8.3 for platforms
79-
// supporting posix_spawn(), see https://github.com/php/php-src/issues/12589
80-
$this->assertStringContainsString('No such file or directory', $e->getMessage());
81-
}
75+
// An invalid command should not fail during start
76+
$this->assertSame('\\' === \DIRECTORY_SEPARATOR ? 1 : 127, $process->run());
8277
}
8378

8479
public function invalidProcessProvider()

0 commit comments

Comments
 (0)