<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Tue May 21 21:48:04 UTC 2013

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
For example:
http://www.doctrine-project.org/jira/si/jira.issueviews:issue-xml/DDC-2317/DDC-2317.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Doctrine Project</title>
    <link>http://www.doctrine-project.org/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>5.2.7</version>
        <build-number>850</build-number>
        <build-date>21-02-2013</build-date>
    </build-info>

<item>
            <title>[DDC-2317] [UnitOfWork] Entity in identityMap but not present in entityIdentifiers</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-2317</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;I&apos;m using symfony 2.1.8 and sonata/admin-bundle&lt;br/&gt;
I have a quite complex entity mapping.&lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;A Competence has many CompetenceAction (superclass)&lt;/li&gt;
	&lt;li&gt;CompetenceActionBuff is a subclass of CompetenceAction and has exactly one buff (selectable in the form by an &apos;entity&apos; field).&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;When i want to edit a Competence, i have the following error message about the Buff entity linked to the CompetenceActionBuff: &lt;br/&gt;
&quot;Entities passed to the choice field must be managed. &lt;span class=&quot;error&quot;&gt;&amp;#91;...&amp;#93;&lt;/span&gt;&quot;&lt;br/&gt;
The exception is raised in Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php at line 412&lt;/p&gt;

&lt;p&gt;I&apos;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.&lt;/p&gt;

&lt;p&gt;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?&lt;/p&gt;

&lt;p&gt;Finally, i tried to comment the test &lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;&lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (!$&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;em-&amp;gt;contains($entity)))&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt; in EntityChoiceList::getIdentifierValues() and everything seemed to work properly.&lt;/p&gt;</description>
                <environment>php 5.4.11, MySQL 5.5, ubuntu 12.10</environment>
            <key id="14548">DDC-2317</key>
            <summary>[UnitOfWork] Entity in identityMap but not present in entityIdentifiers</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="3" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/major.png">Major</priority>
                    <status id="6" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/closed.png">Closed</status>
                    <resolution id="6">Invalid</resolution>
                                <assignee username="ocramius">Marco Pivetta</assignee>
                                <reporter username="rpiotaix">R&#233;mi Piotaix</reporter>
                        <labels>
                        <label>orm</label>
                        <label>unitofwork</label>
                    </labels>
                <created>Sun, 24 Feb 2013 19:57:11 +0000</created>
                <updated>Tue, 26 Feb 2013 08:35:23 +0000</updated>
                    <resolved>Tue, 26 Feb 2013 08:35:23 +0000</resolved>
                            <version>2.3.2</version>
                                                <component>ORM</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="19680" author="ocramius" created="Sun, 24 Feb 2013 20:18:47 +0000"  >&lt;p&gt;Can you please reproduce this in an insulated environment (without symfony forms involved)?&lt;/p&gt;</comment>
                    <comment id="19681" author="rpiotaix" created="Sun, 24 Feb 2013 21:02:10 +0000"  >&lt;p&gt;By doing this, all work properly, the exception is not thrown:&lt;/p&gt;


&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;$competence = $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;getRepo(\Sistearth\JeuBundle\Entity\Competence\Competence::REPO)-&amp;gt;find(1);
$buff = $competence-&amp;gt;getActions()[0]-&amp;gt;getBuff();
      
$em = $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;getDoctrine()-&amp;gt;getEntityManager();
        
&lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt;(!$em-&amp;gt;contains($buff))
    &lt;span class=&quot;code-keyword&quot;&gt;throw&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; \Exception(&lt;span class=&quot;code-quote&quot;&gt;&quot;Not in EntityManager&quot;&lt;/span&gt;);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;but if i add this after:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;$form = $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;createForm(&lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; \Sistearth\JeuBundle\Form\Competence\CompetenceType(), $competence);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;then, the exception &quot;Entities passed to the choice field must be managed. Maybe persist them in the entity manager?&quot; is back.&lt;/p&gt;

&lt;p&gt;I&apos;ll try to do some others tests...&lt;/p&gt;</comment>
                    <comment id="19682" author="ocramius" created="Sun, 24 Feb 2013 21:23:35 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=rpiotaix&quot; class=&quot;user-hover&quot; rel=&quot;rpiotaix&quot;&gt;R&#233;mi Piotaix&lt;/a&gt; the problem is exactly the last bit &lt;img class=&quot;emoticon&quot; src=&quot;http://www.doctrine-project.org/jira/images/icons/emoticons/smile.gif&quot; height=&quot;20&quot; width=&quot;20&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt; Doctrine has no forms, so you will have to create a small script that reproduces the problem without symfony, starting from:&lt;/p&gt;


&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;php composer.phar require doctrine/orm:dev-master@dev&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                    <comment id="19683" author="rpiotaix" created="Sun, 24 Feb 2013 22:22:10 +0000"  >&lt;p&gt;Bug found!&lt;/p&gt;

&lt;p&gt;In the form type CompetenceActionBuffType, i marked the field buff with &lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;array(&apos;by_reference&quot;=&amp;gt;&lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;)&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;. If by_reference is set to false, the modelData is cloned (here the Buff proxy) at line 349 in Form.php.&lt;br/&gt;
And, by cloning the object, the spl_object_hash of the clone is different from the original one&apos;s.&lt;/p&gt;

&lt;p&gt;Is this a symfony Form component bug or a doctrine one?&lt;/p&gt;</comment>
                    <comment id="19688" author="ocramius" created="Tue, 26 Feb 2013 08:35:23 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=rpiotaix&quot; class=&quot;user-hover&quot; rel=&quot;rpiotaix&quot;&gt;R&#233;mi Piotaix&lt;/a&gt; this is a problem of symfony forms, please report it on the symfony issue tracker (check if there&apos;s a similar open issue first) at &lt;a href=&quot;https://github.com/symfony/symfony/issues/&quot; class=&quot;external-link&quot;&gt;https://github.com/symfony/symfony/issues/&lt;/a&gt;&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="11410" name="Buff.php" size="4078" author="rpiotaix" created="Sun, 24 Feb 2013 19:57:11 +0000" />
                    <attachment id="11411" name="Competence.php" size="10366" author="rpiotaix" created="Sun, 24 Feb 2013 19:57:11 +0000" />
                    <attachment id="11412" name="CompetenceAction.php" size="3658" author="rpiotaix" created="Sun, 24 Feb 2013 19:57:11 +0000" />
                    <attachment id="11413" name="CompetenceActionBuff.php" size="1004" author="rpiotaix" created="Sun, 24 Feb 2013 19:57:11 +0000" />
                    <attachment id="11414" name="CompetenceActionBuffType.php" size="1328" author="rpiotaix" created="Sun, 24 Feb 2013 22:23:35 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>