-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] CacheWarmers are never executed in kernel.build_dir
#50357
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
Labels
Comments
nicolas-grekas
added a commit
that referenced
this issue
Oct 17, 2023
…gument to `WarmableInterface::warmup` to warm read-only artefacts in `build_dir` (Okhoshi) This PR was squashed before being merged into the 6.4 branch. Discussion ---------- [FrameworkBundle][HttpKernel] Introduce `$buildDir` argument to `WarmableInterface::warmup` to warm read-only artefacts in `build_dir` | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #50357 | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> See #50357 for the details and the reproduction steps. In this PR, I also moved `ConfigBuilderCacheWarmer` to use the `buildDir` argument. Commits ------- 8b604ff [FrameworkBundle][HttpKernel] Introduce `$buildDir` argument to `WarmableInterface::warmup` to warm read-only artefacts in `build_dir`
Looking at my app with build dir enabled on latest 7.0.x (and ignoring the PRs which are in progress), I can see several artifacts which seem to still be created in
Twig, Router, Validator, Serializer are AFAIK in progress or already merged so should be OK. |
Kocal
added a commit
to symfony/webpack-encore-bundle
that referenced
this issue
Oct 1, 2024
…r (dkarlovi, Kocal) This PR was merged into the 2.x branch. Discussion ---------- fix: correctly wire the build-time file into kernel.build_dir See symfony/symfony#50357 /cc `@Okhoshi` Commits ------- 9f2e8b5 fix(config): remove useless service from #236 e9ef4b5 fix: correctly wire the build-time file into kernel.build_dir
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
While working on #50253, I realised that CacheWarmers are never executed in the
kernel.build_dir
(except in the case of the bug that I fixed in #50253).For now, in a brand new Symfony project, only the compiled container is dumped in the
build_dir
. Looking at the documentation forkernel.build_dir
(Build directory), it is described asHowever, there's plenty of other ressources that could be considered as read-only IMHO: the router cache, Doctrine proxy classes, Symfony Config classes, translations, and probably many more.
Additionally, non-optional CacheWarmers are run during container init, in the
cache_dir
, which is erased if you runcache:clear
command. Since the non-optional CacheWarmers are not executed incache:clear
command, because they run during container init, all the artefacts they produce are actually lost if you runcache:clear
without an already existing container, which is happening on every composer install (some Doctrine CacheWarmers are concerned by this at least).Besides, the mechanism of CacheWarmer seems a bit weird to me in some implementations of the interface. More specifically, the
Symfony\Bundle\FrameworkBundle\Routing\Router
that implements theWarmableInterface
.For reference, here's its implementation of the
warmup
functionIt seems to me that it's really error prone to have such back and forth with the
cache_dir
option. If someone changes thecache_dir
setting of the Router, it won't be properly warmed up anymore, without any notice to the user.So, to sum up a little bit, I can see three different issues, that may or may not be solve together.
build_dir
is under utilised and many read-only warm ups could make use of itcache:clear
WarmableInterface
does not protect from misconfiguration.I'm willing to contribute and propose a change to solve at least the first issue but would like to get some opinions on the best way to solve it beforehand :)
Example
Then see the content of
var/build/dev
andvar/cache/dev
.The text was updated successfully, but these errors were encountered: