<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Wed May 22 03:53:23 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-1010/DDC-1010.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-1010] Crash when fetching results from qb inside postLoad event</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-1010</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;I registered an event listener to my entity manager and on a postLoad event, I want to prepare some data in a nice way (fetch translations for my library + store into associative array into entity). Here&apos;s my snippet:&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 TranslationListener &lt;span class=&quot;code-keyword&quot;&gt;implements&lt;/span&gt; EventSubscriber
{
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function getSubscribedEvents()
    {
        &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; array(Events::postLoad);
    }

    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function postLoad(LifecycleEventArgs $args)
    {
        $em = $args-&amp;gt;getEntityManager();
        $entity = $args-&amp;gt;getEntity();

        &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; ($entity &lt;span class=&quot;code-keyword&quot;&gt;instanceof&lt;/span&gt; Lib) {
            $qb = $em-&amp;gt;createQueryBuilder();
            $qb = $qb-&amp;gt;select(&apos;T&apos;)-&amp;gt;from(&apos;Translate&apos;, &apos;T&apos;)-&amp;gt;join(&apos;T.locale&apos;, &apos;TT&apos;)-&amp;gt;where(&apos;T.lib = ?1&apos;)-&amp;gt;setParameter(1, $entity-&amp;gt;idLib);
            $res = $qb-&amp;gt;getQuery()-&amp;gt;getResult();
            foreach ($res as $tr) {
                $entity-&amp;gt;tr[$tr-&amp;gt;locale-&amp;gt;idLocale] = $tr;
            }
        }
    }
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;When this code is run (eg. getting the Library objects), I got a crash where getResult() is called:&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;
Fatal error: Call to a member function fetch() on a non-object in /home/thepianoguy/testproject/trunk/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php on line 126
Call Stack
#	Time	Memory	Function	Location
1	0.0004	656080	{main}( )	../index.php:0
2	0.1081	18760176	TApplication-&amp;gt;run( )	../index.php:48
3	0.2637	33817288	TApplication-&amp;gt;runService( )	../TApplication.php:382
4	0.2637	33817288	TPageService-&amp;gt;run( )	../TApplication.php:1095
5	0.2698	34788448	TPageService-&amp;gt;runPage( )	../TPageService.php:444
6	0.2715	34986768	TPage-&amp;gt;run( )	../TPageService.php:498
7	0.2716	34989128	TPage-&amp;gt;processNormalRequest( )	../TPage.php:198
8	0.3383	42770128	TControl-&amp;gt;loadRecursive( )	../TPage.php:215
9	0.3383	42770208	ContactUserAddEdit-&amp;gt;onLoad( )	../TControl.php:1286
10	0.3383	42771912	ContactUserAddEdit-&amp;gt;loadData( )	../ContactUserAddEdit.php:56
11	0.3452	43436904	Doctrine\ORM\AbstractQuery-&amp;gt;getResult( )	../ContactUserAddEdit.php:124
12	0.3452	43437296	Doctrine\ORM\AbstractQuery-&amp;gt;execute( )	../AbstractQuery.php:366
13	0.4160	47009328	Doctrine\ORM\Internal\Hydration\AbstractHydrator-&amp;gt;hydrateAll( )	../AbstractQuery.php:537
14	0.4160	47011504	Doctrine\ORM\Internal\Hydration\ObjectHydrator-&amp;gt;_hydrateAll( )	../AbstractHydrator.php:99
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If I comment the line 137 in Doctrine/ORM/Internal/Hydration/AbstractHydrator in _cleanup(), my code works fine:&lt;br/&gt;
//        $this-&amp;gt;_stmt = null;&lt;/p&gt;

&lt;p&gt;I think there is a problem when using alredy used entity manager and query builder inside the postLoad event.&lt;/p&gt;</description>
                <environment>PHP 5.3.3-1ubuntu9.3&lt;br/&gt;
KUbuntu 10.10</environment>
            <key id="12342">DDC-1010</key>
            <summary>Crash when fetching results from qb inside postLoad event</summary>
                <type id="6" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/documentation.png">Documentation</type>
                                <priority id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/minor.png">Minor</priority>
                    <status id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                    <security id="10000">All</security>
                        <assignee username="beberlei">Benjamin Eberlei</assignee>
                                <reporter username="thepianoguy">Matevz Jekovec</reporter>
                        <labels>
                    </labels>
                <created>Tue, 1 Feb 2011 05:16:36 +0000</created>
                <updated>Wed, 23 Jan 2013 22:37:11 +0000</updated>
                                    <version>2.0.1</version>
                                                <component>ORM</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="15208" author="beberlei" created="Wed, 2 Feb 2011 13:37:34 +0000"  >&lt;p&gt;The hydrator is reused internally, this is potentially dangerous as I figure from your use-case.&lt;/p&gt;</comment>
                    <comment id="15209" author="beberlei" created="Wed, 2 Feb 2011 13:45:15 +0000"  >&lt;p&gt;A workaround is to re-registr the object hydrator under a new name&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;$configuration-&amp;gt;setHydrationMode(&lt;span class=&quot;code-quote&quot;&gt;&quot;object2&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;Doctrine\ORM\Internal\Hydration\ObjectHydrator&quot;&lt;/span&gt;);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;and use it in your query.&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;$query-&amp;gt;setHydrationMode(&lt;span class=&quot;code-quote&quot;&gt;&quot;object2&quot;&lt;/span&gt;);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                    <comment id="19387" author="ocramius" created="Wed, 23 Jan 2013 22:37:11 +0000"  >&lt;p&gt;Marking as documentation issue, since the user has to be warned that `postLoad` has to use a dedicated hydrator to execute more load operations.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>