Ver Fonte

[TwigBundle] fixed cache warmer when there is a template with a syntax error

Fabien Potencier há 14 anos atrás
pai
commit
8c89da0004

+ 7 - 1
src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheCacheWarmer.php

@@ -54,8 +54,14 @@ class TemplateCacheCacheWarmer implements CacheWarmerInterface
         $twig = $this->container->get('twig');
 
         foreach ($this->finder->findAllTemplates() as $template) {
-            if ('twig' === $template->get('engine')) {
+            if ('twig' !== $template->get('engine')) {
+                continue;
+            }
+
+            try {
                 $twig->loadTemplate($template);
+            } catch (\Twig_Error $e) {
+                // problem during compilation, give up
             }
         }
     }