Skip to content

[TwigBundle] remove cache warmers when Twig cache is disabled #28029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,15 @@ public function process(ContainerBuilder $container)
$coreThemePath = \dirname(\dirname($reflClass->getFileName())).'/Resources/views/Form';
$container->getDefinition('twig.loader.native_filesystem')->addMethodCall('addPath', array($coreThemePath));

$paths = $container->getDefinition('twig.cache_warmer')->getArgument(2);
$paths = $container->getDefinition('twig.template_iterator')->getArgument(2);
$paths[$coreThemePath] = null;
$container->getDefinition('twig.cache_warmer')->replaceArgument(2, $paths);
$container->getDefinition('twig.template_iterator')->replaceArgument(2, $paths);

if ($container->hasDefinition('twig.cache_warmer')) {
$paths = $container->getDefinition('twig.cache_warmer')->getArgument(2);
$paths[$coreThemePath] = null;
$container->getDefinition('twig.cache_warmer')->replaceArgument(2, $paths);
}
}

if ($container->has('fragment.handler')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ public function load(array $configs, ContainerBuilder $container)

$container->getDefinition('twig')->replaceArgument(1, $config);

if (false === $config['cache']) {
$container->removeDefinition('twig.cache_warmer');
$container->removeDefinition('twig.template_cache_warmer');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does someone remember why we have two cache warmers? Both classes aim to solve the same problem. Is it still necessary to keep both?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at this a LONG time ago for #24608, but I can't remember what my conclusion was. Iirc, they DO indeed do the same thing, but maybe one has one slightly additional feature. Not too helpful, I know :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC TemplateCacheCacheWarmer is the dedicated warmer for templating layer (if enabled), and it's necessary while this layer exists. In the other hand, TemplateCacheWarmer is the new version without templating layer/dependecy.

}

$this->addClassesToCompile(array(
'Twig_Environment',
'Twig_Extension',
Expand Down