Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Can't Fix
-
Affects Version/s: 2.3
-
Fix Version/s: None
-
Component/s: ORM
-
Security Level: All
-
Labels:None
Description
Test script:
$em = $this->getDoctrine()->getEntityManager();
$rows = $em->getRepository('FMECoreBundle:TheListGridRow')
->createQueryBuilder('row')
->getQuery()
->getArrayResult();
var_dump($rows);
Output:
array(3) {
[0]=>
array(2)
[1]=>
array(2)
[2]=>
&array(2)
}
As you can see the last element &array(2) is passed by reference and it broke my code. Can you check this please.
I think it's unexpected behaviour because NOT ALL but only the LAST element in
array is passed by reference. Don't you think?
I provided an example of issue below.
I used the array $rows fetched above and passed it to the setParameter() like
$this->getDoctrine()->getRepository('FMECoreBundle:Admin')
->createQueryBuilder('a')
->where('a.id IN (:ids)')
->setParameter('ids',$rows)
->getQuery()
->getResult();
And now the $rows array contains the following:
array(3) {
{ ["id"]=> int(5) ["rank"]=> int(1) }[0]=>
array(2)
[1]=>
{ ["id"]=> int(6) ["rank"]=> int(2) }array(2)
[2]=>
&int(7)
}
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.
I understand that it'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.
Thanks for your help.
Regards.