[FrameworkBundle] Validator cache fails with annotations #21102
Closed
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.
Validation cache warmup can fail if the validated classes contain annotations that use constants.
The cause is the autoloader introduced in #20830. Using another autoloader in addition to the default composer one changes the behavior of the annotation reader:
DocParser
may check for constants in undefined classes. With the new autoloader that check causes a\ReflectionException
and caching that class fails.This can also cause an error in
LazyLoadingMetadataFactory
: If loading a class fails, valuefalse
may remain in theloadedClasses
property. If that class is a parent of another validated class, merging the parent constraints will now fail.This PR currently includes a fix for the second problem: Invalid state in
LazyLoadingMetadataFactory
is no longer possible. This gets rid of the error, but the cache is still not built correctly as demonstrated by the failing test case. I'm not quite sure how to fix this correctly.Ping @nicolas-grekas
There are still problems to solve: