Skip to content
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

[Validator] ensure the proper context for nested validations #20664

Merged
merged 1 commit into from Nov 29, 2016

Conversation

xabbuh
Copy link
Member

@xabbuh 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

@HeahDude
Copy link
Contributor

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')) {
Copy link
Member

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')) ?

Copy link
Member Author

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.

@fabpot
Copy link
Member

fabpot commented Nov 29, 2016

Thank you @xabbuh.

@fabpot fabpot merged commit 56c8ff8 into symfony:2.7 Nov 29, 2016
fabpot added a commit that referenced this pull request Nov 29, 2016
…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
@xabbuh xabbuh deleted the issue-14786 branch November 29, 2016 08:24
@fabpot fabpot mentioned this pull request Nov 30, 2016
This was referenced Dec 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants