diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php index 10e651b56..5b1038287 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php @@ -46,11 +46,13 @@ class RelationshipNoDuplicateValidator extends ConstraintValidator ]); foreach ($relationships as $r) { - if ( - $r->getFromPerson() === $fromPerson - || $r->getFromPerson() === $toPerson - || $r->getToPerson() === $fromPerson - || $r->getToPerson() === $toPerson + if (spl_object_hash($r) !== spl_object_hash($value) + and + ( + ($r->getFromPerson() === $fromPerson and $r->getToPerson() === $toPerson) + || + ($r->getFromPerson() === $toPerson and $r->getToPerson() === $fromPerson) + ) ) { $this->context->buildViolation($constraint->message) ->addViolation();