Skip to content

Commit

Permalink
bug #36143 [FrameworkBundle] Fix Router Cache (guillbdx)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 4.4 branch.

Discussion
----------

[FrameworkBundle] Fix Router Cache

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #35932
| License       | MIT

RouteCollection config cache didn't have the container file in the tracked resources. If container was recompiled, routes cache was not regenerated. This PR adds the container file to the route collection resources.

Commits
-------

c6ace13 [FrameworkBundle] Fix Router Cache
  • Loading branch information
nicolas-grekas committed Mar 19, 2020
2 parents efb4a7f + c6ace13 commit 7866144
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Symfony/Bundle/FrameworkBundle/Routing/Router.php
Expand Up @@ -15,6 +15,8 @@
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\CompatibilityServiceSubscriberInterface as ServiceSubscriberInterface;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Resource\FileExistenceResource;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\Config\ContainerParametersResource;
use Symfony\Component\DependencyInjection\ContainerInterface as SymfonyContainerInterface;
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
Expand Down Expand Up @@ -71,6 +73,16 @@ public function getRouteCollection()
$this->collection = $this->container->get('routing.loader')->load($this->resource, $this->options['resource_type']);
$this->resolveParameters($this->collection);
$this->collection->addResource(new ContainerParametersResource($this->collectedParameters));

try {
$containerFile = ($this->paramFetcher)('kernel.cache_dir').'/'.($this->paramFetcher)('kernel.container_class').'.php';
if (file_exists($containerFile)) {
$this->collection->addResource(new FileResource($containerFile));
} else {
$this->collection->addResource(new FileExistenceResource($containerFile));
}
} catch (ParameterNotFoundException $exception) {
}
}

return $this->collection;
Expand Down

0 comments on commit 7866144

Please sign in to comment.