<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Sat May 25 04:43:05 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-2178/DDC-2178.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-2178] Last hydrated element is passed by reference</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-2178</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;Test script:&lt;/p&gt;

&lt;p&gt;$em = $this-&amp;gt;getDoctrine()-&amp;gt;getEntityManager();&lt;br/&gt;
$rows = $em-&amp;gt;getRepository(&apos;FMECoreBundle:TheListGridRow&apos;)&lt;br/&gt;
-&amp;gt;createQueryBuilder(&apos;row&apos;)&lt;br/&gt;
-&amp;gt;getQuery()&lt;br/&gt;
-&amp;gt;getArrayResult();&lt;br/&gt;
var_dump($rows);&lt;/p&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;array(3) {&lt;br/&gt;
  &lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt;=&amp;gt;&lt;br/&gt;
  array(2) &lt;/p&gt;
{
    [&quot;id&quot;]=&amp;gt;
    int(5)
    [&quot;rank&quot;]=&amp;gt;
    int(1)
  }
&lt;p&gt;  &lt;span class=&quot;error&quot;&gt;&amp;#91;1&amp;#93;&lt;/span&gt;=&amp;gt;&lt;br/&gt;
  array(2) &lt;/p&gt;
{
    [&quot;id&quot;]=&amp;gt;
    int(6)
    [&quot;rank&quot;]=&amp;gt;
    int(2)
  }
&lt;p&gt;  &lt;span class=&quot;error&quot;&gt;&amp;#91;2&amp;#93;&lt;/span&gt;=&amp;gt;&lt;br/&gt;
  &amp;amp;array(2) &lt;/p&gt;
{
    [&quot;id&quot;]=&amp;gt;
    int(7)
    [&quot;rank&quot;]=&amp;gt;
    int(3)
  }
&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;As you can see the last element &amp;amp;array(2) is passed by reference and it broke my code. Can you check this please.&lt;/p&gt;</description>
                <environment></environment>
            <key id="14281">DDC-2178</key>
            <summary>Last hydrated element is passed by reference</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="7">Can&apos;t Fix</resolution>
                    <security id="10000">All</security>
                        <assignee username="beberlei">Benjamin Eberlei</assignee>
                                <reporter username="menshinskiym">Menshinskiy Mikhail</reporter>
                        <labels>
                    </labels>
                <created>Thu, 29 Nov 2012 10:12:11 +0000</created>
                <updated>Sun, 16 Dec 2012 19:13:38 +0000</updated>
                    <resolved>Sun, 16 Dec 2012 12:13:51 +0000</resolved>
                            <version>2.3</version>
                                                <component>ORM</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="19146" author="beberlei" created="Sun, 16 Dec 2012 12:10:19 +0000"  >&lt;p&gt;broke your code how? I am afraid this is required by the hydration algorithm and cannot be changed.&lt;/p&gt;</comment>
                    <comment id="19151" author="menshinskiym" created="Sun, 16 Dec 2012 19:08:59 +0000"  >&lt;p&gt;I think it&apos;s unexpected behaviour because NOT ALL but only the LAST element in &lt;br/&gt;
array is passed by reference. Don&apos;t you think?&lt;/p&gt;

&lt;p&gt;I provided an example of issue below.&lt;/p&gt;

&lt;p&gt;I used the array $rows fetched above and passed it to the setParameter() like&lt;/p&gt;

&lt;p&gt;$this-&amp;gt;getDoctrine()-&amp;gt;getRepository(&apos;FMECoreBundle:Admin&apos;)&lt;br/&gt;
        -&amp;gt;createQueryBuilder(&apos;a&apos;)&lt;br/&gt;
        -&amp;gt;where(&apos;a.id IN (:ids)&apos;)&lt;br/&gt;
        -&amp;gt;setParameter(&apos;ids&apos;,$rows)&lt;br/&gt;
        -&amp;gt;getQuery()&lt;br/&gt;
        -&amp;gt;getResult();&lt;/p&gt;

&lt;p&gt;And now the $rows array contains the following:&lt;/p&gt;

&lt;p&gt;array(3) {&lt;br/&gt;
&lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt;=&amp;gt;&lt;br/&gt;
array(2) &lt;/p&gt;
{ [&quot;id&quot;]=&amp;gt; int(5) [&quot;rank&quot;]=&amp;gt; int(1) }
&lt;p&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;1&amp;#93;&lt;/span&gt;=&amp;gt;&lt;br/&gt;
array(2) &lt;/p&gt;
{ [&quot;id&quot;]=&amp;gt; int(6) [&quot;rank&quot;]=&amp;gt; int(2) }
&lt;p&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;2&amp;#93;&lt;/span&gt;=&amp;gt;&lt;br/&gt;
&amp;amp;int(7)&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;Of course I already solved this issue, but I have to remember all the time that the last element in hydrated array is passed by reference.&lt;/p&gt;

&lt;p&gt;I understand that it&apos;s a part of hydration algorithm, but I think it would be good to pay attention to this behaviour in the documentation to prevent a future problems.&lt;/p&gt;

&lt;p&gt;Thanks for your help.&lt;br/&gt;
Regards.&lt;/p&gt;
</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>