Skip to content

Commit 8f32ef9

Browse files
committed
Merge branch '7.1' into 7.2
* 7.1: Mitigate PHPUnit deprecations [TwigBundle] Add support for resetting globals between HTTP requests [Process] Fix backwards compatibility for invalid commands Mitigate PHPUnit deprecations [Cache] Fix compatibility with Redis 6.1.0 pre-releases [Validator] Add Catalan and Spanish translation for `Week` constraint Don't use is_resource() on non-streams [Ldap] Fix extension deprecation
2 parents bb0a8b7 + d704e30 commit 8f32ef9

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

Process.php

Lines changed: 8 additions & 2 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
@@ -367,7 +372,7 @@ public function start(?callable $callback = null, array $env = []): void
367372
restore_error_handler();
368373
}
369374

370-
if (!\is_resource($process)) {
375+
if (!$process) {
371376
throw new ProcessStartFailedException($this, $lastError);
372377
}
373378
$this->process = $process;
@@ -1429,8 +1434,9 @@ private function readPipes(bool $blocking, bool $close): void
14291434
private function close(): int
14301435
{
14311436
$this->processPipes->close();
1432-
if (\is_resource($this->process)) {
1437+
if ($this->process) {
14331438
proc_close($this->process);
1439+
$this->process = null;
14341440
}
14351441
$this->exitcode = $this->processInformation['exitcode'];
14361442
$this->status = self::STATUS_TERMINATED;

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)