8000 bug #24908 [WebServerBundle] Prevent console.terminate from being fir… · symfony/symfony@e68919a · GitHub
[go: up one dir, main page]

Skip to content

Commit e68919a

Browse files
committed
bug #24908 [WebServerBundle] Prevent console.terminate from being fired when server:start finishes (kbond)
This PR was merged into the 3.4 branch. Discussion ---------- [WebServerBundle] Prevent console.terminate from being fired when server:start finishes | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #24885 | License | MIT | Doc PR | n/a When the cache is cleared between `server:start` and `server:stop` the container used in `server:start` is no longer valid. Firing the `console.terminate` event throws an exception. This PR clears the event dispatcher so `console.terminate` is not fired. Commits ------- 699339e [WebServerBundle] prevent console.terminate from being fired after stopping server
2 parents 9b3bf5d + 699339e commit e68919a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\Console\Output\OutputInterface;
2020
use Symfony\Component\Console\Output\ConsoleOutputInterface;
2121
use Symfony\Component\Console\Style\SymfonyStyle;
22+
use Symfony\Component\EventDispatcher\EventDispatcher;
2223

2324
/**
2425
* Runs a local web server in a background process.
@@ -132,6 +133,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
132133
$io->error('Running this server in production environment is NOT recommended!');
133134
}
134135

136+
// replace event dispatcher with an empty one to prevent console.terminate from firing
137+
// as container could have changed between start and stop
138+
$this->getApplication()->setDispatcher(new EventDispatcher());
139+
135140
try {
136141
$server = new WebServer();
137142
if ($server->isRunning($input->getOption('pidfile'))) {

0 commit comments

Comments
 (0)
0