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

Skip to content

[symfony/process] BC break with Process::isTerminated() when a process fail at start #57946

Closed
@steevanb

Description

@steevanb

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions