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

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Jul 23, 2018

Q A
Branch? 2.8
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #28009
License MIT
Doc PR

@@ -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.

@yceruto
Copy link
Member

yceruto commented Jul 23, 2018

This part should be updated as well:

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

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

$container->getDefinition('twig.template_iterator')->replaceArgument(2, $paths);
Copy link
Member

Choose a reason for hiding this comment

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

variable $paths is undefined if twig.cache_warmer doesn't exist, it must be included in the new if condition.

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

Choose a reason for hiding this comment

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

either this service should be also removed when cache is disabled, or its configuration here should not be disabled when disabling the cache warming.

@fabpot
Copy link
Member

fabpot commented Sep 4, 2018

@xabbuh Can you finish this PR?

@xabbuh
Copy link
Member Author

xabbuh commented Sep 4, 2018

comments should be addressed now

@fabpot
Copy link
Member

fabpot commented Sep 4, 2018

Thank you @xabbuh.

@fabpot fabpot merged commit ef1f7ff into symfony:2.8 Sep 4, 2018
fabpot added a commit that referenced this pull request Sep 4, 2018
…led (xabbuh)

This PR was merged into the 2.8 branch.

Discussion
----------

[TwigBundle] remove cache warmers when Twig cache is disabled

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #28009
| License       | MIT
| Doc PR        |

Commits
-------

ef1f7ff remove cache warmers when Twig cache is disabled
@xabbuh xabbuh deleted the issue-28009 branch September 4, 2018 09:11
This was referenced Sep 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants