Reputation: 597
I've just upgraded from Symfony 2.1 to 2.2. I followed the instructions given here:
http://symfony.com/blog/symfony-2-2-0
https://github.com/symfony/symfony/blob/2.2/UPGRADE-2.2.md
All my code was working beautifully before, but now there is some kind of problem where the framework is injecting "_fragment" into the URL after I try to do something in my application. This is changing my URL from:
http://server/app_dev.php/en-GB/
to:
http://server/app_dev.php/_fragment/
This is then being picked up as the locale by twig and causes it to fail with the following error:
An exception has been thrown during the rendering of a template
("Circular reference detected when adding a fallback catalogue for locale "".")
in "/var/....../HomeBundle/Resources/views/Home/index.html.twig".
2/2 Twig_Error_Runtime: An exception has been thrown during the rendering of a template
("Circular reference detected when adding a fallback catalogue for locale "".")
in "/var/...../HomeBundle/Resources/views/Home/index.html.twig"
1/2 LogicException: Circular reference detected when adding a fallback catalogue for locale "".
Part of the back trace says:
DEBUG - Notified event "kernel.exception" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelException".
DEBUG - Notified event "kernel.exception" to listener "Symfony\Component\HttpKernel\EventListener\ExceptionListener::onKernelException".
CRITICAL - Uncaught PHP Exception Twig_Error_Runtime: "An exception has been thrown during the rendering of a template ("Circular reference detected when adding a fallback catalogue for locale "".") in "/var/...../HomeBundle/Resources/views/Home/index.html.twig"." at /var/...../app/cache/dev/classes.php line 6030
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\SessionListener::onKernelRequest".
When I first login to the application, it all seems to be working fine, the request lists the locale as it should be:
_locale "en-GB"
_route "_home_index"
_route_params "Array(_locale => en-GB)"
However, if I then click on another link (including going back to the same page), it fails with the above error and changes the request to:
_locale "_fragment"
_route "_home_index"
_route_params "Array(_locale => _fragment)"
My routing (for the above example) looks like this:
Home_Home:
resource: "@HomeBundle/Controller/HomeController.php"
type: annotation
prefix: /{_locale}
defaults: { _locale: en }
My config:
framework:
translator: { fallback: en }
default_locale: en
I don't think the problem is the locale handling, but rather with the new fragment sub-handling framework that was added to Symfony 2.2. Possibly it is being called/activated in some way? (or I'm missing some kind of configuration).
Upvotes: 0
Views: 1548
Reputation: 597
I think I found that problem at least, simply adding a fragments configuration item in config.yml fixed that particular issue:
framework:
fragments: { path: /_fragment }
Upvotes: 1