Skip to content

Commit 4f90ccd

Browse files
Merge branch '5.2' into 5.3
* 5.2: [Console] Run commands when implements SignalableCommandInterface without pcntl and they have'nt signals [Form] Fix 'invalid_message' use in multiple ChoiceType [Form] fix some type annotations
2 parents a8106e7 + f62eda5 commit 4f90ccd

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
947947
}
948948
}
949949

950-
if ($command instanceof SignalableCommandInterface) {
950+
if ($command instanceof SignalableCommandInterface && ($this->signalsToDispatchEvent || $command->getSubscribedSignals())) {
951951
if (!$this->signalRegistry) {
952952
throw new RuntimeException('Unable to subscribe to signal events. Make sure that the `pcntl` extension is installed and that "pcntl_*" functions are not disabled by your php.ini\'s "disable_functions" directive.');
953953
}

Tests/ApplicationTest.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
use Symfony\Component\Console\Output\Output;
3838
use Symfony\Component\Console\Output\OutputInterface;
3939
use Symfony\Component\Console\Output\StreamOutput;
40+
use Symfony\Component\Console\SignalRegistry\SignalRegistry;
4041
use Symfony\Component\Console\Tester\ApplicationTester;
4142
use Symfony\Component\DependencyInjection\ContainerBuilder;
4243
use Symfony\Component\EventDispatcher\EventDispatcher;
@@ -1863,6 +1864,18 @@ public function testSignal()
18631864
$this->assertTrue($command->signaled);
18641865
$this->assertTrue($dispatcherCalled);
18651866
}
1867+
1868+
public function testSignalableCommandInterfaceWithoutSignals()
1869+
{
1870+
$command = new SignableCommand();
1871+
1872+
$dispatcher = new EventDispatcher();
1873+
$application = new Application();
1874+
$application->setAutoExit(false);
1875+
$application->setDispatcher($dispatcher);
1876+
$application->add($command);
1877+
$this->assertSame(0, $application->run(new ArrayInput(['signal'])));
1878+
}
18661879
}
18671880

18681881
class CustomApplication extends Application
@@ -1930,7 +1943,7 @@ class SignableCommand extends Command implements SignalableCommandInterface
19301943

19311944
public function getSubscribedSignals(): array
19321945
{
1933-
return [\SIGALRM];
1946+
return SignalRegistry::isSupported() ? [\SIGALRM] : [];
19341947
}
19351948

19361949
public function handleSignal(int $signal): void

0 commit comments

Comments
 (0)