Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1492

Fatall error: Cannot use object as array in ORM\Internal\Hydration\ObjectHydrator.php on line 314

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.1.1
    • Fix Version/s: 2.2
    • Component/s: None
    • Security Level: All
    • Labels:
      None
    • Environment:
      Symfony2, Doctrine 2.1.1 (also bug present on 2.1.3-dev - latest revison of 2.1.x branch)

      Description

      My entities

      event
      eveht.event_area_id=event_area.id (1:1)
      event_area.event_id=event.id (1:1)
      event_area.area.id=area.id (one area has many event_area's)
      area.parent_id=area_id (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.

        Activity

        Hide
        Guilherme Blanco added a comment -

        https://github.com/doctrine/doctrine2/commit/77e076f1fdbe24fdb2f5a1fb1842c0b9cb7d95a4

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

        Thanks

        Show
        Guilherme Blanco added a comment - https://github.com/doctrine/doctrine2/commit/77e076f1fdbe24fdb2f5a1fb1842c0b9cb7d95a4 This issue was fixed in master. I requested Benjamin to merge this with 2.1 branch. Thanks
        Hide
        Konstantin added a comment -

        yes, with this line of code this query works.

        Show
        Konstantin added a comment - yes, with this line of code this query works.
        Hide
        Guilherme Blanco added a comment - - edited

        Hi.

        If you change this line:

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

        To this:

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

        Does it work for you?

        Show
        Guilherme Blanco added a comment - - edited Hi. If you change this line: $parentObject = $ this ->_resultPointers[$parentAlias][key($first)]; To this: $parentObject = $first[key($first)]; Does it work for you?
        Hide
        Konstantin added a comment -

        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
        
        Show
        Konstantin added a comment - 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
        Hide
        Benjamin Eberlei added a comment -

        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).

        Show
        Benjamin Eberlei added a comment - 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).

          People

          • Assignee:
            Guilherme Blanco
            Reporter:
            Konstantin
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: