[FrameworkBundle] enable metadata cache when annotation is disabled #49679
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When using Annotations, annotations are cached at
AnnotationLoader
level.Which is cleared when entities are changed. So the dev experience is optimal.
When using yaml files, there is no cache at the loader level so I added in the past the same cache as for the prod env, as the metadata are effectively cleared when using only yaml config files.
#35109
The regression introduced by my patch is for people that do not use mapping files but use annotations.
#41961
But now, we are in the opposite situation: no cache for people using mapping files but not annotations.
On a current project it means loading 83 yaml files for each dev requests. It's not good at all.
A simple local fix is to add that in a dev services files.
A solution in Symfony could be:
1/ only yaml/xml mapping files (
enable_annotations: false
) : cache like prod => that what I did in this PR, as it fixes the current perf regressions on my different projects. There is no cache on yaml/xml file as soon as annotation is enabled (which is the default)2/ add a cache at reader level for yaml/xml loader
3/ add a cache cleaner at metadata level when annotation are enabled