Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[TwigBundle] added a Twig templates warmer when templating is disabled #16271

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, 2015

Conversation

fabpot
Copy link
Member

@fabpot fabpot commented Oct 17, 2015

Q A
Bug fix? yes
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR n/a

When disabling the templating component, Twig templates are not warmed up as the warmer depends on the template finder which needs the templating component. This PR adds a new cache warmer that covers this case.

see #16262

@fabpot fabpot force-pushed the twig-template-warmer branch 3 times, most recently from 5699644 to f9ccf12 Compare October 17, 2015 16:20
private $twig;
private $iterator;

public function __construct(Twig_Environment \$twig, \Iterator $iterator)
Copy link
Contributor

Choose a reason for hiding this comment

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

\Twig_Environment $twig

@fabpot fabpot force-pushed the twig-template-warmer branch from f9ccf12 to a3363dc Compare October 17, 2015 17:38
private $twig;
private $iterator;

public function __construct(\Twig_Environment $twig, \Iterator $iterator)
Copy link
Contributor

Choose a reason for hiding this comment

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

Passing \Iterator $iterator looks wrong, it should be \Traversable ?

Copy link
Contributor

Choose a reason for hiding this comment

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

true, it's currently broken anyway: it passed an InteratorAggregate but expects an Iterator

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@fabpot fabpot force-pushed the twig-template-warmer branch from a3363dc to 5cb63cf Compare October 18, 2015 20:17
@fabpot
Copy link
Member Author

fabpot commented Oct 18, 2015

Should be ok now.

@tucksaun
Copy link
Contributor

👍

'@Bar/index.html.twig',
'@Foo/index.html.twig',
'layout.html.twig',
'sub/sub.html.twig',
Copy link
Contributor

Choose a reason for hiding this comment

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

on windows fails, I think DIRECTORY_SEPARATOR fixed it

'sub'.DIRECTORY_SEPARATOR.'sub.html.twig',

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

Copy link
Member Author

Choose a reason for hiding this comment

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

I've normalized the output of the generator instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the normalization is not the best way. Twig internally doesn't normalize either.

Copy link
Member

Choose a reason for hiding this comment

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

but Twig uses what the developer uses as name, which may not be the DIRECTORY_SEPARATOR (it is even likely it is not, because you don't have access to this constant easily when including a template)

Copy link
Contributor

Choose a reason for hiding this comment

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

no, when twig resolves namespaces, it uses the local filesystem separators in its final path

Copy link
Member

Choose a reason for hiding this comment

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

@Tobion this iterator is meant to return template names, not cache keys. So it is the input of the Twig resolution, not the output.

@fabpot fabpot force-pushed the twig-template-warmer branch from 5cb63cf to bd3701b Compare October 19, 2015 09:33
@aitboudad
Copy link
Contributor

👍

status: reviewed

@stof
Copy link
Member

stof commented Oct 19, 2015

👍

even with the templating component enabled, templates accessed using the Twig native notation were not warmed up btw.

@fabpot fabpot merged commit bd3701b into symfony:2.8 Oct 19, 2015
fabpot added a commit that referenced this pull request Oct 19, 2015
…ting is disabled (fabpot)

This PR was merged into the 2.8 branch.

Discussion
----------

[TwigBundle] added a Twig templates warmer when templating is disabled

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

When disabling the templating component, Twig templates are not warmed up as the warmer depends on the template finder which needs the templating component. This PR adds a new cache warmer that covers this case.

see #16262

Commits
-------

bd3701b [TwigBundle] added a Twig templates warmer when templating is disabled
@ghost
Copy link

ghost commented Oct 26, 2015

@stof Any idea how to fix this?

@fabpot fabpot mentioned this pull request Nov 16, 2015
fabpot added a commit that referenced this pull request Sep 30, 2016
…rmer introduced in 2.8 (tucksaun)

This PR was merged into the 2.8 branch.

Discussion
----------

[TwigBundle] Adjust CacheWarmingTest for TemplateCacheWarmer introduced in 2.8

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

With #20103, issue reported in #20065 is fixed, however it will now break in 2.8+ as another cache warmer has been introduced with #16271.

Commits
-------

360ca48 [TwigBundle] Adjust CacheWarmingTest for TemplateCacheWarmer introduced in 2.8
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