DDC-1492: Fatall error: Cannot use object as array in ORM\Internal\Hydration\ObjectHydrator.php on line 314 #2121

Closed
doctrinebot opened this Issue Nov 13, 2011 · 6 comments

2 participants

@doctrinebot

Jira issue originally created by user koc:

My entities

event
eveht.eventarea_id=eventarea.id (1:1)
eventarea.eventid=event.id (1:1)
eventarea.area.id=area.id (one area has many eventarea's)
area.parentid=areaid (hierarchial)
event.author_id=user.id (one user has many events)

area - STI: District/City/Region/Country/etc.

SELECT
    r, ra, a, ap, au, DATE(r.eventTime) AS event_date
FROM OloloEventsBundle:Event r
    LEFT JOIN r.eventArea ra
        LEFT JOIN ra.area a
            LEFT JOIN a.parent ap
    INNER JOIN r.author au WHERE r.eventTime <= :r*eventtime AND ra.area IN(:ra*area)
GROUP BY r
ORDER BY event_date DESC

This DQL caused an error "Cannot use object of type District as array in ORM\Internal\Hydration\ObjectHydrator.php on line 314". When I'm removing ap friom fetching - it works. Mapping are correct - there are many other places where it works correctly.

@doctrinebot

Comment created by @beberlei:

On 2.1.1 line 314 is a "}". Can you restate the line and add a stack trace if possible (xdebug or phpunit can help there).

@doctrinebot

Comment created by koc:

Sorry, line was changed cause I've updated to 2.1.3-dev.

( ! ) Fatal error: Cannot use object of type Ololo\Bundle\TerritorialBundle\Entity\District as array in Z:\home\dev\Ololo\code\vendors\Doctrine\Orm\lib\Doctrine\ORM\Internal\Hydration\ObjectHydrator.php on line 308
Call Stack
#   Time    Memory  Function    Location
1   0.0006  333520  {main}( )   ..\index_dev.php:0
2   0.0254  1435584 Symfony\Component\HttpKernel\Kernel->handle( )  ..\index_dev.php:20
3   0.2454  3634168 Symfony\Bundle\FrameworkBundle\HttpKernel->handle( )    ..\Kernel.php:171
4   0.2454  3634576 Symfony\Component\HttpKernel\HttpKernel->handle( )  ..\HttpKernel.php:44
5   0.2454  3634576 Symfony\Component\HttpKernel\HttpKernel->handleRaw( )   ..\HttpKernel.php:71
6   0.3589  5534264 call*user_func*array ( )    ..\HttpKernel.php:117
7   0.3590  5534448 Ololo\Bundle\DistrictsBundle\Controller\DistrictController->EventsPastAction( ) ..\HttpKernel.php:0
8   1.1606  13782464    Ololo\Bundle\EventsBundle\Entity\EventRepository->getPastEventsByAreasIds( )    ..\DistrictController.php:145
9   1.1607  13783520    Ololo\Bundle\EventsBundle\Entity\EventRepository->getEventsSliceBySpecification( )  ..\EventRepository.php:385
10  1.2010  14224216    Doctrine\ORM\AbstractQuery->getResult( )    ..\EventRepository.php:477
11  1.2010  14224368    Doctrine\ORM\AbstractQuery->execute( )  ..\AbstractQuery.php:392
12  3.3409  14781264    Doctrine\ORM\Internal\Hydration\AbstractHydrator->hydrateAll( ) ..\AbstractQuery.php:594
13  3.3412  14785824    Doctrine\ORM\Internal\Hydration\ObjectHydrator->_hydrateAll( )  ..\AbstractHydrator.php:99
14  3.3413  14798576    Doctrine\ORM\Internal\Hydration\ObjectHydrator->_hydrateRow( )  ..\ObjectHydrator.php:140
                    $parentObject = $this->*resultPointers[$parentAlias][key($first)]; // trouble here, $this->*resultPointers[$parentAlias] is object of District
@doctrinebot

Comment created by @guilhermeblanco:

Hi.

If you change this line:

$parentObject = $this->_resultPointers[$parentAlias][key($first)];

To this:

$parentObject = $first[key($first)];

Does it work for you?

@doctrinebot

Comment created by koc:

yes, with this line of code this query works.

@doctrinebot

Comment created by @guilhermeblanco:

77e076f

This issue was fixed in master.
I requested Benjamin to merge this with 2.1 branch.

Thanks

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added this to the 2.2 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment