Skip to content

Commit

Permalink
bug #24908 [WebServerBundle] Prevent console.terminate from being fir…
Browse files Browse the repository at this point in the history
…ed 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
  • Loading branch information
fabpot committed Nov 10, 2017
2 parents 9b3bf5d + 699339e commit e68919a
Showing 1 changed file with 5 additions and 0 deletions.
Expand Up @@ -19,6 +19,7 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\EventDispatcher\EventDispatcher;

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

// replace event dispatcher with an empty one to prevent console.terminate from firing
// as container could have changed between start and stop
$this->getApplication()->setDispatcher(new EventDispatcher());

try {
$server = new WebServer();
if ($server->isRunning($input->getOption('pidfile'))) {
Expand Down

0 comments on commit e68919a

Please sign in to comment.