Skip to content

Conversation

okhoshi
Copy link
Contributor

@okhoshi okhoshi commented Mar 23, 2024

Q A
Branch? 7.3
Bug fix? no
New feature? yes
Deprecations? no
Issues none
License MIT

Follow up to #50391, set up the Twig TemplateCacheWarmer to use the kernel.build_dir instead of kernel.cache_dir. A new argument is added to its constructor to specify the directory to use for the cache.

@okhoshi okhoshi requested a review from yceruto as a code owner March 23, 2024 21:49
@carsonbot carsonbot added this to the 7.1 milestone Mar 23, 2024
@okhoshi okhoshi force-pushed the twig-cache-build-dir branch 6 times, most recently from fb68b3c to 0bc3774 Compare March 24, 2024 14:59
@okhoshi okhoshi force-pushed the twig-cache-build-dir branch from 0bc3774 to c5b4ab0 Compare March 25, 2024 06:31
@okhoshi okhoshi force-pushed the twig-cache-build-dir branch from c5b4ab0 to 95b994c Compare March 25, 2024 08:04
Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

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

Very good idea.

@okhoshi okhoshi force-pushed the twig-cache-build-dir branch 2 times, most recently from 0dbdd9b to 40e485c Compare March 27, 2024 10:41
@stof
Copy link
Member

stof commented Mar 27, 2024

shouldn't this dual cache setup be disabled when autoReload is enabled ? Otherwise, any template cached in the readonly cache won't be reloaded (as the cache never writes the new content) which will break the DX

@okhoshi
Copy link
Contributor Author

okhoshi commented Mar 27, 2024

shouldn't this dual cache setup be disabled when autoReload is enabled ? Otherwise, any template cached in the readonly cache won't be reloaded (as the cache never writes the new content) which will break the DX

I don't think it needs to. Looking at the Environment::loadTemplate method, it skips the cache::load call if autoReload is enabled, and calls cache::write directly. As the ChainCache propagates the write to all caches, from that moment, only the Runtime cache will be used, with the updated copy of the template.
Or did I miss something ?

Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

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

I tested it on a project and got some functional feedback.

@GromNaN
Copy link
Member

GromNaN commented Apr 11, 2025

Tests are failing.

Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException: You have requested a non-existent parameter "kernel.build_dir". Did you mean this: "kernel.cache_dir"?

…uild time

Signed-off-by: Quentin Devos <4972091+Okhoshi@users.noreply.github.com>
@okhoshi okhoshi force-pushed the twig-cache-build-dir branch from a0bbca5 to 0f841d2 Compare April 11, 2025 15:04
@okhoshi
Copy link
Contributor Author

okhoshi commented Apr 11, 2025

Tests are failing.

Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException: You have requested a non-existent parameter "kernel.build_dir". Did you mean this: "kernel.cache_dir"?

Fixed, I didn't realise the tests were using a smaller kernel.

@okhoshi
Copy link
Contributor Author

okhoshi commented May 8, 2025

@GromNaN @fabpot @nicolas-grekas @OskarStark Could we still get this merged in 7.3 ?

@fabpot
Copy link
Member

fabpot commented May 10, 2025

Thank you @okhoshi.

@fabpot fabpot merged commit 532e408 into symfony:7.3 May 10, 2025
7 of 11 checks passed
@okhoshi okhoshi deleted the twig-cache-build-dir branch May 10, 2025 08:41
@fabpot fabpot mentioned this pull request May 10, 2025
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request May 12, 2025
…ache config (Okhoshi)

This PR was merged into the 7.3 branch.

Discussion
----------

[Twig] [TwigBundle] Describe the new behaviour of twig.cache config

Update the description of the `twig.cache` config to follow the changes implemented in symfony/symfony#54384.

Fixes #20948

cc `@alexandre`-daubois

Commits
-------

8c5f22b [TwigBundle] Describe the new behaviour of twig.cache config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature ❄️ Feature Freeze Important Pull Requests to finish before the next Symfony "feature freeze" Status: Reviewed TwigBundle
Projects
None yet
Development

Successfully merging this pull request may close these issues.