Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitad63d0b

Browse files
PaolaRubynicolas-grekas
authored andcommitted
[Console] Run commands when implements SignalableCommandInterface without pcntl and they have'nt signals
1 parent1f6a5a7 commitad63d0b

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

‎src/Symfony/Component/Console/Application.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
940940
}
941941
}
942942

943-
if ($commandinstanceof SignalableCommandInterface) {
943+
if ($commandinstanceof SignalableCommandInterface && ($this->signalsToDispatchEvent ||$command->getSubscribedSignals())) {
944944
if (!$this->signalRegistry) {
945945
thrownewRuntimeException('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.');
946946
}

‎src/Symfony/Component/Console/Tests/ApplicationTest.php‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
useSymfony\Component\Console\Output\Output;
3737
useSymfony\Component\Console\Output\OutputInterface;
3838
useSymfony\Component\Console\Output\StreamOutput;
39+
useSymfony\Component\Console\SignalRegistry\SignalRegistry;
3940
useSymfony\Component\Console\Tester\ApplicationTester;
4041
useSymfony\Component\DependencyInjection\ContainerBuilder;
4142
useSymfony\Component\EventDispatcher\EventDispatcher;
@@ -1861,6 +1862,18 @@ public function testSignal()
18611862
$this->assertTrue($command->signaled);
18621863
$this->assertTrue($dispatcherCalled);
18631864
}
1865+
1866+
publicfunctiontestSignalableCommandInterfaceWithoutSignals()
1867+
{
1868+
$command =newSignableCommand();
1869+
1870+
$dispatcher =newEventDispatcher();
1871+
$application =newApplication();
1872+
$application->setAutoExit(false);
1873+
$application->setDispatcher($dispatcher);
1874+
$application->add($command);
1875+
$this->assertSame(0,$application->run(newArrayInput(['signal'])));
1876+
}
18641877
}
18651878

18661879
class CustomApplicationextends Application
@@ -1928,7 +1941,7 @@ class SignableCommand extends Command implements SignalableCommandInterface
19281941

19291942
publicfunctiongetSubscribedSignals():array
19301943
{
1931-
return [\SIGALRM];
1944+
returnSignalRegistry::isSupported() ?[\SIGALRM] : [];
19321945
}
19331946

19341947
publicfunctionhandleSignal(int$signal):void

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp