-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] ensure the proper context for nested validations #20664
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
xabbuh
commented
Nov 28, 2016
Q | A |
---|---|
Branch? | 2.7 |
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #14639, #20368 |
License | MIT |
Doc PR | n/a |
A necessary feature since 2.7 is LTS and this bug's really tricky |
@@ -110,6 +111,11 @@ public function validate($value, $constraints = null, $groups = null) | |||
$previousMetadata = $this->context->getMetadata(); | |||
$previousPath = $this->context->getPropertyPath(); | |||
$previousGroup = $this->context->getGroup(); | |||
$previousConstraint = null; | |||
|
|||
if ($this->context instanceof ExecutionContext || method_exists($this->context, 'getConstraint')) { |
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.
Why not just if (method_exists($this->context, 'getConstraint'))
?
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.
I did not test it, but the instanceof
check should be faster and should be true most of the time.
Thank you @xabbuh. |
…ns (xabbuh) This PR was merged into the 2.7 branch. Discussion ---------- [Validator] ensure the proper context for nested validations | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #14639, #20368 | License | MIT | Doc PR | n/a Commits ------- 56c8ff8 ensure the proper context for nested validations