Skip to content

Adding the Form default theme files to be warmed up in Twig's cache #24608

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
Oct 19, 2017

Conversation

weaverryan
Copy link
Member

@weaverryan weaverryan commented Oct 18, 2017

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

Hiya guys!

So..... during a Symfony Live workshop, we found out that the form theme Twig templates are not included in the Twig cache warmup process. This fixes that. I believe this is the only "weird" case where we use a Twig template that is not in a bundle and also not added to Twig as a proper namespaces.

I tested this on a 2.8 project. Before the patch, the form theme templates were not warmed up. After, they are warmed up. Booya.

Cheers!

@fabpot
Copy link
Member

fabpot commented Oct 18, 2017

Can't it be merged in 2.7 as well?

$coreThemePath = dirname(dirname($reflClass->getFileName())).'/Resources/views/Form';
$container->getDefinition('twig.loader.native_filesystem')->addMethodCall('addPath', array($coreThemePath));

$paths = $container->getParameter('twig.cache_warmer_paths');
Copy link
Member

Choose a reason for hiding this comment

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

I don't like the use of a parameter. That exposes internal details.

@weaverryan weaverryan force-pushed the warmup-form-theme-paths branch from 3e346d9 to 2ef619f Compare October 19, 2017 02:19
@weaverryan
Copy link
Member Author

weaverryan commented Oct 19, 2017

Ok, fixed back to not introduce a new parameter. I just tried again, it still works fine.

This applies only to 2.8 and above. In 2.7, the cache warmer doesn't have a third (paths) argument at all: https://github.com/symfony/symfony/blob/2.7/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml#L48

So... it could technically be fixed in 2.7, but would be much different than this patch... the paths arg from 2.8 would need to be backported. Should we?

@nicolas-grekas nicolas-grekas added this to the 2.8 milestone Oct 19, 2017
@fabpot
Copy link
Member

fabpot commented Oct 19, 2017

Thank you @weaverryan.

@fabpot fabpot merged commit 2ef619f into symfony:2.8 Oct 19, 2017
fabpot added a commit that referenced this pull request Oct 19, 2017
…g's cache (weaverryan)

This PR was merged into the 2.8 branch.

Discussion
----------

Adding the Form default theme files to be warmed up in Twig's cache

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

Hiya guys!

So..... during a Symfony Live workshop, we found out that the form theme Twig templates are *not* included in the Twig cache warmup process. This fixes that. I believe this is the only "weird" case where we use a Twig template that is not in a bundle and also not added to Twig as a proper namespaces.

I tested this on a 2.8 project. Before the patch, the form theme templates were not warmed up. After, they are warmed up. Booya.

Cheers!

Commits
-------

2ef619f Adding the Form default theme files to be warmed up in Twig's cache
This was referenced Oct 30, 2017
This was referenced Nov 10, 2017
@weaverryan weaverryan deleted the warmup-form-theme-paths branch August 8, 2018 15:19
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.

4 participants