From 36e41b85d8890a0e8a7cc4c07b41bc06b1055bf7 Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Fri, 16 Oct 2020 14:31:14 +0200 Subject: [PATCH] [Console] Fix Application::getSignalRegistry() retval --- src/Symfony/Component/Console/Application.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 0e98d9bdd53cd..0efccdb103002 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -110,6 +110,10 @@ public function setCommandLoader(CommandLoaderInterface $commandLoader) public function getSignalRegistry(): SignalRegistry { + if (!$this->signalRegistry) { + throw new RuntimeException('Signals are not supported. Make sure that the `pcntl` extension is installed and that "pcntl_*" functions are not disabled by your php.ini\'s "disable_functions" directive.'); + } + return $this->signalRegistry; } @@ -282,7 +286,7 @@ public function doRun(InputInterface $input, OutputInterface $output) $command = $this->find($alternative); } - if ($this->dispatcher) { + if ($this->dispatcher && $this->signalRegistry) { foreach ($this->signalsToDispatchEvent as $signal) { $event = new ConsoleSignalEvent($command, $input, $output, $signal); @@ -954,7 +958,7 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI } if ($command instanceof SignalableCommandInterface) { - if (!$this->signalsToDispatchEvent) { + if (!$this->signalRegistry) { 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.'); } foreach ($command->getSubscribedSignals() as $signal) {