symfony: [symfony/process] BC break with Process::isTerminated() when a process fail at start
Symfony version(s) affected
7.1.0
Description
Before 7.1, when a process failed at start because the command does not exists, nothing was different from a process who failed because of the exit code of the command.
Since 7.1, when the command does not exists (example: unknown-command), a new ProcessStartFailedException is throwned. It’s interesting, why not, but then, $process->isTerminated() always return false. Before 7.1 (7.0, 6.x and before), in this particular case, $process->isTerminated() returned true.
From my point of view, it’s a huge bc break, because we can’t just try / catch the new exception, all the code who use $process->isTerminated() should be modified.
How to reproduce
$process = new Process(['unkown-command']);
try {
$process->run();
// This exception is throwned in 7.1, but doesn't exists before (7.0, 6.x etc)
} catch (\Symfony\Component\Process\Exception\ProcessStartFailedException) {
}
var_dump(
$process->isStarted(), // all versions : true
$process->isTerminated(), // 7.0 and before : true, 7.1 : false
$process->isSuccessful() // all versions : false
);
See https://github.com/steevanb/symfony-issue-57946
Possible Solution
To be honnest, i don’t know. Since Process::isTerminated() do not return a stored property, but call updateStatus() then check $this->status, I don’t know how to fix it.
Additional Context
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 18 (12 by maintainers)
Same as #57722 by @ToshY indeed.
I had a quick look and my advice here would be to retry calling proc_open with a string instead of an array when the array fails. This should lead to restoring the previous behavior.
Anyone up for a PR?
@xabbuh no. This looks different (even though it is related). This issue does not complain about the fact we throw a ProcessStartFailedException but about the fact that a process that fails starting is not considered terminated after catching the exception.