Skip to content

Commit

Permalink
bug #24971 [FrameworkBundle] Empty event dispatcher earlier in CacheC…
Browse files Browse the repository at this point in the history
…learCommand (nicolas-grekas)

This PR was merged into the 3.4 branch.

Discussion
----------

[FrameworkBundle] Empty event dispatcher earlier in CacheClearCommand

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Once the cache folder is emptied, the event dispatcher cannot be used because service factories are gone. This currently fails very badly when an error is dispatched, but the error listeners are themselves failing to be loaded for this reason.

Commits
-------

a961392 [FrameworkBundle] Empty event dispatcher earlier in CacheClearCommand
  • Loading branch information
nicolas-grekas committed Nov 16, 2017
2 parents e70c1f8 + a961392 commit 3398c4b
Showing 1 changed file with 3 additions and 3 deletions.
Expand Up @@ -111,6 +111,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io->comment(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
$this->cacheClearer->clear($realCacheDir);

// The current event dispatcher is stale, let's not use it anymore
$this->getApplication()->setDispatcher(new EventDispatcher());

if ($input->getOption('no-warmup')) {
$this->filesystem->rename($realCacheDir, $oldCacheDir);
} else {
Expand All @@ -129,9 +132,6 @@ protected function execute(InputInterface $input, OutputInterface $output)

$this->filesystem->remove($oldCacheDir);

// The current event dispatcher is stale, let's not use it anymore
$this->getApplication()->setDispatcher(new EventDispatcher());

if ($output->isVerbose()) {
$io->comment('Finished');
}
Expand Down

0 comments on commit 3398c4b

Please sign in to comment.