merged branch jmikola/patch-2 (PR #3535)
Commits -------a5ed6ab
[DoctrineBridge] Rewind MongoCursor before use in unique validator Discussion ---------- [DoctrineBridge] Rewind MongoCursor before use in unique validator Fixes a regression I introduced in:265360d142
--------------------------------------------------------------------------- by jmikola at 2012-03-08T22:11:32Z This was also reported in doctrine/DoctrineMongoDBBundle#84. Let it be stated that we should create some functional tests for this validator :)
This commit is contained in:
commit
c21c3bb1e2
@ -94,6 +94,14 @@ class UniqueEntityValidator extends ConstraintValidator
|
||||
$repository = $em->getRepository($className);
|
||||
$result = $repository->findBy($criteria);
|
||||
|
||||
/* If the result is a MongoCursor, it must be advanced to the first
|
||||
* element. Rewinding should have no ill effect if $result is another
|
||||
* iterator implementation.
|
||||
*/
|
||||
if ($result instanceof \Iterator) {
|
||||
$result->rewind();
|
||||
}
|
||||
|
||||
/* If no entity matched the query criteria or a single entity matched,
|
||||
* which is the same as the entity being validated, the criteria is
|
||||
* unique.
|
||||
|
Reference in New Issue
Block a user