From 5c1bcb9289c7fb563f50b88c2798426d941f68a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Wed, 9 Apr 2025 00:27:30 +0200 Subject: [PATCH] [TwigBundle] Skip build dir warmup when auto-reload is enabled --- .../TwigBundle/CacheWarmer/TemplateCacheWarmer.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheWarmer.php b/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheWarmer.php index 868dc076cfd9e..5fd9030886540 100644 --- a/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheWarmer.php +++ b/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheWarmer.php @@ -41,6 +41,17 @@ public function warmUp(string $cacheDir, ?string $buildDir = null): array { $this->twig ??= $this->container->get('twig'); + // No cache, nothing to warmup + if (!$this->twig->getCache()) { + return []; + } + + // When auto-reload is enabled, cache don't need to be warmed up during the initial build. + // This speedups dev env when the build dir is configured. + if ($buildDir && $this->twig->isAutoReload()) { + return []; + } + foreach ($this->iterator as $template) { try { $this->twig->load($template);