Description
There is a problem when the cache is created using cache:clear
where the config twig[autoescape_service]
is ignored.
I have tried to find how this happens and failed, but I have created a test application that shows it happening.
https://github.com/mcfedr/symfony-twig-error
If the cache is cleared manually, rm -rf app/cache
, then the template will load correctly, and be cached correctly, using the escaping as specified by the configured service.
But if the template is loaded during the warming, via cache:clear
, then it will use the default twig escaping guesser, Symfony\Bundle\TwigBundle\TwigEngine::guessDefaultEscapingStrategy
.
Running cache:warm
does not exhibit this bug
Adding to the fun, the cached Container (appProdProjectContainer
) correctly sets the option
protected function getTemplatingService()
{
$this->services['templating'] = $instance = new \Symfony\Bundle\TwigBundle\TwigEngine($this->get('twig'), $this->get('templating.name_parser'), $this->get('templating.locator'));
$instance->setDefaultEscapingStrategy(array(0 => $this->get('mcfedr_twig_error.twig_escaping'), 1 => 'guess'));
return $instance;
}