Skip to content

Routing cache is broken with multi-kernel setup on 4.3 #32069

Closed
@eXtreme

Description

@eXtreme

Symfony version(s) affected: 4.3.0, 4.3.1

Description

I upgraded my app (which is set up with multiple kernels) to 4.3 and the routing is broken. In previous versions a cached UrlMatcher (and UrlGenerator) had a filename that depended on kernel name (like apiApiKernelProdContainerUrlMatcher.php). Right now it is always UrlMatcher.php and comes from the first kernel that was booted after clearing the cache. Which means that running a different kernel will have a wrong route configuration.

I know that using multiple-kernels is "no longer recommended" but it wasn't when I started the project and it was working perfectly fine before 4.3.

How to reproduce

https://github.com/eXtreme/symfony-multikernel-bug

Simple app set up with symfony binary, and simplest multi-kernel setup like in the docs. Two front controllers: index.php and api.php and they should run different controllers but run the one that was from the first cached kernel.

Additional context

jacek@jacek-zenbook:~/Work/symfony-multikernel-bug$ ls var/cache/dev/ | cat
annotations.map
ContainerMbPNwx5
ContainerWs8RPPA
doctrine
pools
profiler
srcApp_ApiKernelDevDebugContainerCompiler.log
srcApp_ApiKernelDevDebugContainerDeprecations.log
srcApp_ApiKernelDevDebugContainer.php
srcApp_ApiKernelDevDebugContainer.php.meta
srcApp_ApiKernelDevDebugContainer.xml
srcApp_ApiKernelDevDebugContainer.xml.meta
srcApp_KernelDevDebugContainerCompiler.log
srcApp_KernelDevDebugContainerDeprecations.log
srcApp_KernelDevDebugContainer.php
srcApp_KernelDevDebugContainer.php.meta
srcApp_KernelDevDebugContainer.xml
srcApp_KernelDevDebugContainer.xml.meta
twig
UrlGenerator.php
UrlGenerator.php.meta
UrlMatcher.php
UrlMatcher.php.meta

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions