symfony/symfony — pull request #4625 by stof (2012-06-20 20:25:45+00:00)
Title: Fixed the validation of form validation constraints

Validating the form constraints for each validation group results in
duplicated errors when several validation groups are used.

This is an attempt to fix #4427.

@bschussek can you look at it ? I'm not sure if it is the right way to fix it.

Looking at the code of the GraphWalker to debug this, I think we have an issue in the validator component itself (and the Form constraints being only the easiest way to trigger the issue): if a constraint is attached on an object in 2 validation groups and you use both groups when calling the validator, the ConstraintValidator is called twice. This is not something you will generally do in your constraint mapping, but the FormValidator was working in such a way: form constraints were validated for all validation groups of the form. However, I don't see how the GraphWalker could remember the constraint has already been validated for this instance as walkConstraint does not have access to the object.