<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Sat May 25 07:50:07 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-1734/DDC-1734.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-1734] Uninitialized proxies cannot be serialized properly</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-1734</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;I have the following entity:&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;class Currency
{
    /** @Id @Column(type=&lt;span class=&quot;code-quote&quot;&gt;&quot;string&quot;&lt;/span&gt;) */
    &lt;span class=&quot;code-keyword&quot;&gt;protected&lt;/span&gt; $code;
        
    /** @Column(type=&lt;span class=&quot;code-quote&quot;&gt;&quot;string&quot;&lt;/span&gt;) */    
    &lt;span class=&quot;code-keyword&quot;&gt;protected&lt;/span&gt; $name;
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;When I serialize an object graph which references a Currency proxy, but this proxy is initialized, then this works as expected:&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;O:65:&lt;span class=&quot;code-quote&quot;&gt;&quot;Application\Domain\Proxy\__CG__\Application\Domain\Model\Currency&quot;&lt;/span&gt;:3:{s:17:&lt;span class=&quot;code-quote&quot;&gt;&quot;__isInitialized__&quot;&lt;/span&gt;;b:1;s:7:&lt;span class=&quot;code-quote&quot;&gt;&quot;*code&quot;&lt;/span&gt;;s:3:&lt;span class=&quot;code-quote&quot;&gt;&quot;USD&quot;&lt;/span&gt;;s:7:&lt;span class=&quot;code-quote&quot;&gt;&quot;*name&quot;&lt;/span&gt;;s:20:&lt;span class=&quot;code-quote&quot;&gt;&quot;United States Dollar&quot;&lt;/span&gt;;}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;However, if the proxy is not initialized, then all properties are serialized as null, and the identity is lost:&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;O:65:&lt;span class=&quot;code-quote&quot;&gt;&quot;Application\Domain\Proxy\__CG__\Application\Domain\Model\Currency&quot;&lt;/span&gt;:3:{s:17:&lt;span class=&quot;code-quote&quot;&gt;&quot;__isInitialized__&quot;&lt;/span&gt;;b:0;s:7:&lt;span class=&quot;code-quote&quot;&gt;&quot;*code&quot;&lt;/span&gt;;N;s:7:&lt;span class=&quot;code-quote&quot;&gt;&quot;*name&quot;&lt;/span&gt;;N;}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;That makes a merge() impossible once stored in a session, as the identity of the entity is now unknown.&lt;/p&gt;

&lt;p&gt;I think the solution might be:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;either to have the proxy&apos;s $_identity field serialized as well&lt;/li&gt;
	&lt;li&gt;or to have the $code (identity field) populated when the proxy is created.&lt;/li&gt;
&lt;/ul&gt;
</description>
                <environment></environment>
            <key id="13570">DDC-1734</key>
            <summary>Uninitialized proxies cannot be serialized properly</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="5" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/resolved.png">Resolved</status>
                    <resolution id="1">Fixed</resolution>
                    <security id="10000">All</security>
                        <assignee username="ocramius">Marco Pivetta</assignee>
                                <reporter username="benjamin">Benjamin Morel</reporter>
                        <labels>
                    </labels>
                <created>Thu, 29 Mar 2012 09:21:30 +0000</created>
                <updated>Thu, 21 Feb 2013 10:13:45 +0000</updated>
                    <resolved>Thu, 21 Feb 2013 10:13:45 +0000</resolved>
                            <version>2.2</version>
                                                <component>ORM</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>5</watches>
                        <comments>
                    <comment id="17731" author="ocramius" created="Tue, 3 Apr 2012 00:38:29 +0000"  >&lt;p&gt;I am personally for dropping the `$_identifier` field and using the entity fields themselves. Will check this tomorrow. (also: not sure if it is possible, just checking)&lt;/p&gt;</comment>
                    <comment id="17823" author="beberlei" created="Sat, 7 Apr 2012 07:41:38 +0000"  >&lt;p&gt;This is not fixable. The Proxy requires access to the Entity Persister when unserialized, but that is not available anymore. Proxies are broken if unserialized and then accessed, i believe an exception is thrown in this case.&lt;/p&gt;</comment>
                    <comment id="17831" author="benjamin" created="Sat, 7 Apr 2012 11:30:52 +0000"  >&lt;p&gt;Of course they cannot be initialized once unserialized, but should&apos;nt be merge()able to a new EntityManager anyway?&lt;/p&gt;

&lt;p&gt;What I would imagine is:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;Serialize the identity as part of the proxy&lt;/li&gt;
	&lt;li&gt;If used when unserialized, throw an exception (see &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DDC-1732&quot; class=&quot;external-link&quot;&gt;http://www.doctrine-project.org/jira/browse/DDC-1732&lt;/a&gt;)&lt;/li&gt;
	&lt;li&gt;If found during a merge(), replace the proxy with a fresh proxy/entity from the current EntityManager&lt;/li&gt;
&lt;/ul&gt;
</comment>
                    <comment id="18899" author="benjamin" created="Tue, 30 Oct 2012 06:21:07 +0000"  >&lt;p&gt;@Marco Pivetta This is a great idea. Have you checked if it is possible?&lt;br/&gt;
I&apos;m really surprised that a proxied entity&apos;s identity is lost forever upon serialization.&lt;/p&gt;</comment>
                    <comment id="19081" author="mnapoli" created="Fri, 30 Nov 2012 13:42:46 +0000"  >&lt;p&gt;Can this issue be reopened please?&lt;/p&gt;

&lt;p&gt;As Benjamin Morel said, it is expected that the proxy is broken once unserialized, but it should be possible to merge to the EntityManager and then use it.&lt;/p&gt;

&lt;p&gt;For now, objects graphs with proxies can&apos;t be serialized! It could be if the merge would resolve the situation.&lt;/p&gt;

&lt;p&gt;I&apos;m giving it a try by serializing the $_identifier field in the Proxy&lt;/p&gt;

&lt;p&gt;Thanks&lt;/p&gt;</comment>
                    <comment id="19084" author="ocramius" created="Fri, 30 Nov 2012 14:36:28 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=benjamin&quot; class=&quot;user-hover&quot; rel=&quot;benjamin&quot;&gt;Benjamin Morel&lt;/a&gt; you can check my implementation for &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DCOM-96&quot; title=&quot;Extract a common ProxyFactory&quot;&gt;&lt;del&gt;DCOM-96&lt;/del&gt;&lt;/a&gt; at &lt;a href=&quot;https://github.com/doctrine/common/pull/168&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/common/pull/168&lt;/a&gt; and &lt;a href=&quot;https://github.com/doctrine/doctrine2/pull/406&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/doctrine2/pull/406&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="19085" author="ocramius" created="Fri, 30 Nov 2012 14:37:36 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=matthieu&quot; class=&quot;user-hover&quot; rel=&quot;matthieu&quot;&gt;Matthieu Napoli&lt;/a&gt; can you try adding $identifier at &lt;a href=&quot;https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Proxy/ProxyFactory.php#L319-L323&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Proxy/ProxyFactory.php#L319-L323&lt;/a&gt; ?&lt;/p&gt;</comment>
                    <comment id="19086" author="mnapoli" created="Fri, 30 Nov 2012 15:14:43 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=ocramius&quot; class=&quot;user-hover&quot; rel=&quot;ocramius&quot;&gt;Marco Pivetta&lt;/a&gt; Yes that&apos;s what I&apos;m planning to do. I&apos;ve written a testcase that reproduces the bug right now.&lt;/p&gt;</comment>
                    <comment id="19087" author="ocramius" created="Fri, 30 Nov 2012 16:00:28 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=matthieu&quot; class=&quot;user-hover&quot; rel=&quot;matthieu&quot;&gt;Matthieu Napoli&lt;/a&gt; awesome. If you can attach the test here, it would be possible to add it to the proxy refactoring.&lt;/p&gt;</comment>
                    <comment id="19088" author="mnapoli" created="Fri, 30 Nov 2012 16:22:08 +0000"  >&lt;p&gt;@ocramius I will make a pull request on Github and post the link here.&lt;/p&gt;

&lt;p&gt;However I&apos;m sort of stuck right now: I&apos;ve added &apos;_identifier&apos; to the fields serialized, but it&apos;s not enough. To merge, the UoW needs to initialize the proxy to get the identifiers (because $_identifier is private in the proxy). Problem: $_entityPersister (used to initialize the proxy) is also private.&lt;/p&gt;

&lt;p&gt;So I can neither get the identifier of the proxy (even for creating a new proxy for example), nor feed it a new entityPersister to load it... The solution would be to change the proxy a bit (like adding a &quot;__setEntityPersister&quot; method for example) but I guess that changing the Proxy interface in &quot;Doctrine\Common&quot; is a large change and that will not be accepted as a pull request...&lt;/p&gt;

&lt;p&gt;Any ideas ?&lt;/p&gt;</comment>
                    <comment id="19089" author="ocramius" created="Fri, 30 Nov 2012 16:23:54 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=matthieu&quot; class=&quot;user-hover&quot; rel=&quot;matthieu&quot;&gt;Matthieu Napoli&lt;/a&gt; I wouldn&apos;t start hacking on that right now... The new impl allows injecting an initializer. A hack may be ok-ish, but the API is already at its EOL.&lt;/p&gt;</comment>
                    <comment id="19090" author="ocramius" created="Fri, 30 Nov 2012 16:25:49 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=matthieu&quot; class=&quot;user-hover&quot; rel=&quot;matthieu&quot;&gt;Matthieu Napoli&lt;/a&gt; I&apos;d think of marking this as to be fixed in 2.4.x&lt;/p&gt;</comment>
                    <comment id="19091" author="mnapoli" created="Fri, 30 Nov 2012 16:42:26 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=ocramius&quot; class=&quot;user-hover&quot; rel=&quot;ocramius&quot;&gt;Marco Pivetta&lt;/a&gt; I&apos;m working on the master branch, it&apos;s 2.4 right? I don&apos;t see anything different for the proxies in this branch (I don&apos;t see any way to inject an initializer).&lt;/p&gt;

&lt;p&gt;Or is it your PR (&lt;a href=&quot;https://github.com/doctrine/common/pull/168&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/common/pull/168&lt;/a&gt;) maybe?&lt;/p&gt;</comment>
                    <comment id="19092" author="benjamin" created="Fri, 30 Nov 2012 17:09:47 +0000"  >&lt;p&gt;I&apos;m happy that this bug is taken care of, I think that&apos;s a major problem that&apos;s been dismissed a bit quickly.&lt;br/&gt;
Can the bug be reopened, with fix version 2.4, to avoid forgetting it once more?&lt;/p&gt;</comment>
                    <comment id="19093" author="mnapoli" created="Fri, 30 Nov 2012 17:17:24 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=benjamin&quot; class=&quot;user-hover&quot; rel=&quot;benjamin&quot;&gt;Benjamin Morel&lt;/a&gt; +1&lt;/p&gt;</comment>
                    <comment id="19094" author="ocramius" created="Fri, 30 Nov 2012 18:11:33 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=mnapoli&quot; class=&quot;user-hover&quot; rel=&quot;mnapoli&quot;&gt;Matthieu Napoli&lt;/a&gt; yes, that&apos;s the PR. Please let me know for the tests so that I can add them to doctrine/common.&lt;br/&gt;
I&apos;m re-opening the issue&lt;/p&gt;</comment>
                    <comment id="19095" author="ocramius" created="Fri, 30 Nov 2012 18:12:15 +0000"  >&lt;p&gt;Re-opening issue - need test to verify the behavior before proceeding.&lt;/p&gt;</comment>
                    <comment id="19098" author="mnapoli" created="Mon, 3 Dec 2012 08:57:11 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=ocramius&quot; class=&quot;user-hover&quot; rel=&quot;ocramius&quot;&gt;Marco Pivetta&lt;/a&gt; Sorry the test was on my computer at work, here it is now: &lt;a href=&quot;https://gist.github.com/4193721&quot; class=&quot;external-link&quot;&gt;https://gist.github.com/4193721&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Just to be clear: I created 2 test methods, the first one works (there is no serialization step), the second doesn&apos;t. This is to make it clear that the serialization step is the problem. I hope this is alright.&lt;/p&gt;</comment>
                    <comment id="19099" author="ocramius" created="Mon, 3 Dec 2012 09:25:13 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=mnapoli&quot; class=&quot;user-hover&quot; rel=&quot;mnapoli&quot;&gt;Matthieu Napoli&lt;/a&gt; thank you for the test. But please fix the tests so that both fail (if these are actually two verified cases).&lt;/p&gt;</comment>
                    <comment id="19100" author="mnapoli" created="Mon, 3 Dec 2012 09:33:10 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=ocramius&quot; class=&quot;user-hover&quot; rel=&quot;ocramius&quot;&gt;Marco Pivetta&lt;/a&gt; No those aren&apos;t 2 different cases, they are the same, it&apos;s just that one fails because we use serialization (this is the problem described in this ticket), and the other one works because we don&apos;t use serialization (and it only exists to check that everything works if we don&apos;t use serialization). Actually I think the &quot;working test&quot; has no reason to exist really, I just made it to &quot;prove&quot; that the problem was indeed the serialization, so it can be removed.&lt;/p&gt;</comment>
                    <comment id="19101" author="ocramius" created="Mon, 3 Dec 2012 09:34:53 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=mnapoli&quot; class=&quot;user-hover&quot; rel=&quot;mnapoli&quot;&gt;Matthieu Napoli&lt;/a&gt; ok, so I can basically strip the working one &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;&lt;/p&gt;</comment>
                    <comment id="19235" author="ocramius" created="Sun, 6 Jan 2013 13:58:29 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=mnapoli&quot; class=&quot;user-hover&quot; rel=&quot;mnapoli&quot;&gt;Matthieu Napoli&lt;/a&gt; I deployed a fix in &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DCOM-96&quot; title=&quot;Extract a common ProxyFactory&quot;&gt;&lt;del&gt;DCOM-96&lt;/del&gt;&lt;/a&gt; ( &lt;a href=&quot;https://github.com/doctrine/doctrine2/pull/406&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/doctrine2/pull/406&lt;/a&gt; &lt;a href=&quot;https://github.com/Ocramius/doctrine2/commit/1424cc781277a4f8183229c5e8d838724e1ca879&quot; class=&quot;external-link&quot;&gt;https://github.com/Ocramius/doctrine2/commit/1424cc781277a4f8183229c5e8d838724e1ca879&lt;/a&gt; )&lt;/p&gt;</comment>
                    <comment id="19320" author="mnapoli" created="Tue, 15 Jan 2013 15:19:23 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=ocramius&quot; class=&quot;user-hover&quot; rel=&quot;ocramius&quot;&gt;Marco Pivetta&lt;/a&gt; fantastic!&lt;/p&gt;</comment>
                    <comment id="19409" author="beberlei" created="Fri, 25 Jan 2013 16:25:23 +0000"  >&lt;p&gt;A related Github Pull-Request &lt;span class=&quot;error&quot;&gt;&amp;#91;GH-247&amp;#93;&lt;/span&gt; was opened&lt;br/&gt;
&lt;a href=&quot;https://github.com/doctrine/common/pull/247&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/common/pull/247&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="19423" author="beberlei" created="Sat, 26 Jan 2013 23:53:36 +0000"  >&lt;p&gt;A related Github Pull-Request &lt;span class=&quot;error&quot;&gt;&amp;#91;GH-247&amp;#93;&lt;/span&gt; was closed&lt;br/&gt;
&lt;a href=&quot;https://github.com/doctrine/common/pull/247&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/common/pull/247&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="19581" author="ocramius" created="Thu, 21 Feb 2013 10:13:45 +0000"  >&lt;p&gt;Resolved in &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DCOM-96&quot; title=&quot;Extract a common ProxyFactory&quot;&gt;&lt;del&gt;DCOM-96&lt;/del&gt;&lt;/a&gt;&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>