symfony/symfony — pull request #3450 by jmikola (2012-02-25 22:24:01+00:00)
Title: [DoctrineBridge] Simpler result checking in UniqueEntityValidator

In 928e352d09a6bb0b566e61bc7482ead1d4859442, support for MongoDB cursors was implemented by converting an Iterable, non-ArrayAccess object to an array. The ArrayAccess check didn't seem purposeful, since cursors are only Iterable and ORM returns real arrays. Since we only need to access the first element of the cursor (and only in cases where the count is exactly 1), we can simply use current() to handle Iterables and arrays.

@henrikbjorn: Any thoughts on this? I was testing @stof's work in doctrine/DoctrineMongoDBBundle#68 and our Symfony submodule was a bit old, so I fixed UniqueEntityValidator on my local machine before I realized you had come up with a solution a few weeks ago.