merged branch jmikola/doctrine-unique-proxies (PR #3933)
Commits
-------
41bdf26
[DoctrineBridge] Initialize proxies in UniqueEntityValidator
Discussion
----------
[DoctrineBridge] Initialize proxies in UniqueEntityValidator
Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: [![Build Status](https://secure.travis-ci.org/jmikola/symfony.png?branch=master)](http://travis-ci.org/jmikola/symfony)
Fixes the following tickets: #3163
---------------------------------------------------------------------------
by stof at 2012-04-13T18:17:57Z
I think you should use ``$em->initializeObject($value)`` instead (which is a no-op for other objects)
---------------------------------------------------------------------------
by jmikola at 2012-04-13T18:24:22Z
@stof: Thanks for the suggestion. I wasn't aware of that method.
This commit is contained in:
commit
8e59a4ed79
@ -78,6 +78,12 @@ class UniqueEntityValidator extends ConstraintValidator
|
||||
}
|
||||
|
||||
if ($class->hasAssociation($fieldName)) {
|
||||
/* Ensure the Proxy is initialized before using reflection to
|
||||
* read its identifiers. This is necessary because the wrapped
|
||||
* getter methods in the Proxy are being bypassed.
|
||||
*/
|
||||
$em->initializeObject($criteria[$fieldName]);
|
||||
|
||||
$relatedClass = $em->getClassMetadata($class->getAssociationTargetClass($fieldName));
|
||||
$relatedId = $relatedClass->getIdentifierValues($criteria[$fieldName]);
|
||||
|
||||
|
Reference in New Issue
Block a user