-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
LazyLoadingMetadataFactory looks broken #21538
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
Conversation
This looks like it is caused by the changes done in #21053. I am not sure if your use case really makes much sense to be honest. |
$factory = new LazyLoadingMetadataFactory($reader); | ||
$metadata = $factory->getMetadataFor('Symfony\Component\Validator\Tests\Fixtures\EntityStaticCarTurbo'); | ||
$classMetaData = $metadata->getPropertyMetadata('wheels'); | ||
$constraints = $classMetaData[0]->getConstraints(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The culprit here is that you are making the assumption that getPropertyMetadata()
of the ClassMetadata
class will online return one PropertyMetadata
instance (or that the one you need is the first entry in the returned collection). It's true that this was the case before #20793, but that IMO is can implementation detail you shouldn't rely on (the RecursiveContextualValidator
, for example, iterates over the return property metadata). I'll see if we can nonetheless update the code to only return one instance, but as said that's not something I would rely on.
Hello, |
fabbot failures must be fixed. |
…sses (angelk, xabbuh) This PR was merged into the 2.7 branch. Discussion ---------- [Validator] property constraints can be added in child classes | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #21538, #21567 | License | MIT | Doc PR | This reverts the changes done in #21053 (and applies the test written by @angelk in #21538). I think trying to "fix" #15950 with the changes from #21053 was a mistake. Child classes should be able to refine validation constraints (I basically agree with @ro0NL's reasoning in #21567 (comment). Commits ------- 9513a8a property constraints can be added in child classes a266ff7 added test for staticClassLoader in LazyLoadingMetadatafactory
I'm expecting to have all parent classes in constraint group. By the [docs] (http://symfony.com/doc/current/validation/groups.html)
Testing with LazyLoadingMetadataFactory from v3.2.1 works fine.