Skip to content

[TwigBundle] Twig cache warm up is not idempotent #21130

Closed
@4rthem

Description

@4rthem
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.2

Since Twig uses template path in its cache key, the latter differs when performing cache:warmup for the first or the second time. So I have to run cache:warmup twice in order to get all the templates generated.

At the first run, the service templating.cache_warmer.template_paths fills var/cache/prod/templates.php which contains relative paths like __DIR__.'/../../../vendor/foo/bar/Resources/views/blabla.html.twig'. But at this time the DI container provides a TemplateLocator which has no /templates.php cache file (see constructor) so the var/cache/prod/../../../ part is omitted.

It's only at the second run, when /templates.php exists, that we get a TemplateLocator using these cached paths. In this case, the final cache key is used and templates are properly generated in their final path.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions