mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-2317: [UnitOfWork] Entity in identityMap but not present in entityIdentifiers #2909
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Feb 24, 2013).
Originally assigned to: @Ocramius on GitHub.
Jira issue originally created by user rpiotaix:
I'm using symfony 2.1.8 and sonata/admin-bundle
I have a quite complex entity mapping.
When i want to edit a Competence, i have the following error message about the Buff entity linked to the CompetenceActionBuff:
"Entities passed to the choice field must be managed. [...]"
The exception is raised in Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php at line 412
I've added some debug code in the EntityManager::contains() method and it shows that my entity is in the entityMap but his oid is not in the keys of entityIdentifiers making the call to UnitOfWork::isInIdentityMap() return false at line 1505.
When submitting the form, there is no problems. All the entities are correctly created in the database. The exception is thrown only when i want to edit the Competence object. Saying that the Buff object is not managed when it was first loaded from the database... strange, no?
Finally, i tried to comment the test
if (!$this->em->contains($entity)))in EntityChoiceList::getIdentifierValues() and everything seemed to work properly.@doctrinebot commented on GitHub (Feb 24, 2013):
Comment created by @ocramius:
Can you please reproduce this in an insulated environment (without symfony forms involved)?
@doctrinebot commented on GitHub (Feb 24, 2013):
Comment created by rpiotaix:
By doing this, all work properly, the exception is not thrown:
but if i add this after:
then, the exception "Entities passed to the choice field must be managed. Maybe persist them in the entity manager?" is back.
I'll try to do some others tests...
@doctrinebot commented on GitHub (Feb 24, 2013):
Comment created by @ocramius:
[~rpiotaix] the problem is exactly the last bit :) Doctrine has no forms, so you will have to create a small script that reproduces the problem without symfony, starting from:
php composer.phar require doctrine/orm:dev-master@dev@doctrinebot commented on GitHub (Feb 24, 2013):
Comment created by rpiotaix:
Bug found!
In the form type CompetenceActionBuffType, i marked the field buff with
array('by*reference"=>false). If by_reference is set to false, the modelData is cloned (here the Buff proxy) at line 349 in Form.php.And, by cloning the object, the spl_object*hash of the clone is different from the original one's.
Is this a symfony Form component bug or a doctrine one?
@doctrinebot commented on GitHub (Feb 26, 2013):
Comment created by @ocramius:
[~rpiotaix] this is a problem of symfony forms, please report it on the symfony issue tracker (check if there's a similar open issue first) at https://github.com/symfony/symfony/issues/
@doctrinebot commented on GitHub (Feb 26, 2013):
Issue was closed with resolution "Invalid"