Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2516

Undefined offset in ObjectHydrator while working with iterableResult

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.3.4
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • Labels:
    • Environment:
      using Symfony2

      Description

      Following this documentation page http://doctrine-orm.readthedocs.org/en/2.0.x/reference/batch-processing.html#iterating-large-results-for-data-processing I tried to create a batch process on 75k entities. But an error came in the ObjectHydrator on line 511 there's an Undefined offset. Now, i just use the SimpleObjectHydrator and it solve the problem. but i'm wondering if it's a real bug or just a miss use of Doctrine.
      Reproduce this error could be hard so ask if you want me to give you more informations about it.

        Activity

        Hide
        Benjamin Eberlei added a comment -

        Can you provide more information? The stack trace of the error for example? The entity you try to process+mapping and the DQL query. The current information is not enough to reproduce this error.

        Show
        Benjamin Eberlei added a comment - Can you provide more information? The stack trace of the error for example? The entity you try to process+mapping and the DQL query. The current information is not enough to reproduce this error.
        Hide
        Johanny Clerc-Renaud added a comment -

        Hello Benjamin,

        here is the Entity and with the corresponding Mapping :

        Entity.php
            /**
             * @var string
             * @ORM\Id
             * @ORM\Column(name="id_source", type="string", length=32, nullable=false)
             */
            private $idSource;
            
            /**
             * @var string
             *
             * @ORM\Column(name="id_page", type="string", length=32, nullable=false)
             */
            private $idPage;
        
            /**
             * @var string
             *
             * @ORM\Column(name="url", type="string", length=500, nullable=true)
             */
            private $url;
        
            /**
             * @var float
             *
             * @ORM\Column(name="similitude", type="decimal", nullable=true)
             */
            private $similitude;
        
            /**
             * @var string
             *
             * @ORM\Column(name="alerte", type="string", length=512, nullable=true)
             */
            private $alerte;
        

        The Entity have been generated by using this documentation page : http://symfony.com/doc/current/cookbook/doctrine/reverse_engineering.html

        In this project I work with 2 databases, and one of it already exist.

        Working with symfony I use the DQL Query obtain with those methods :

        EntityRepository.php
            public function getAllUrl($limit)
            {
                $queryBuilder = $this->createQueryBuilder('s');
        
                $this->setStatsParameters($queryBuilder);
        
                $queryBuilder->setMaxResults($limit);
                
                return $queryBuilder->getQuery()
                                    ->iterate();
            }
        
            private function setStatsParameters(\Doctrine\ORM\QueryBuilder $queryBuilder)
            {
                $queryBuilder->where('s.similitude > 1')
                             ->andWhere('s.url NOT LIKE :url')
                             ->setParameter('url', 'some_string%');
            }
        

        And here is the stack trace, when the eror comes :

        stackTrace.log
        Exception trace:
         () at \path\to\project\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\ObjectHydrator.php:511
         Symfony\Component\Debug\ErrorHandler->handle() at \path\to\project\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\ObjectHydrator.php:511
         Doctrine\ORM\Internal\Hydration\ObjectHydrator->hydrateRowData() at \path\to\project\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\AbstractHydrator.php:136
         Doctrine\ORM\Internal\Hydration\AbstractHydrator->hydrateRow() at \path\to\project\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\IterableResult.php:76
         Doctrine\ORM\Internal\Hydration\IterableResult->next() at \path\to\project\src\Compilatio\RecolteurBundle\Command\RecolteurCommand.php:42
         CompanyName\RecolteurBundle\Command\RecolteurCommand->execute() at \path\to\project\vendor\symfony\symfony\src\Symfony\Component\Console\Command\Command.php:244
         Symfony\Component\Console\Command\Command->run() at \path\to\project\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:906
         Symfony\Component\Console\Application->doRunCommand() at \path\to\project\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:191
         Symfony\Component\Console\Application->doRun() at \path\to\project\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Console\Application.php:80
         Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at \path\to\project\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:121
         Symfony\Component\Console\Application->run() at \path\to\project\app\console:27
        

        You can also see here the source code that lead to this error :

        command.php
          $sources = $urlLoader->getAllSources(50000);
        
          $number = 0;
          while (($source = $sources->next()) !== false) {
              $number++;
          }
          echo 'Nombre de sources : ' . $number;
        

        There are all the information you ask, if you need more just tell me. For now i can see how to be more specific. Remember that if I switch the hydrator to Query::HYDRATE_SIMPLEOBJECT it solve the bug.

        I hope all of this will help.

        Regards,

        Johanny

        Show
        Johanny Clerc-Renaud added a comment - Hello Benjamin, here is the Entity and with the corresponding Mapping : Entity.php /** * @ var string * @ORM\Id * @ORM\Column(name= "id_source" , type= "string" , length=32, nullable= false ) */ private $idSource; /** * @ var string * * @ORM\Column(name= "id_page" , type= "string" , length=32, nullable= false ) */ private $idPage; /** * @ var string * * @ORM\Column(name= "url" , type= "string" , length=500, nullable= true ) */ private $url; /** * @ var float * * @ORM\Column(name= "similitude" , type= "decimal" , nullable= true ) */ private $similitude; /** * @ var string * * @ORM\Column(name= "alerte" , type= "string" , length=512, nullable= true ) */ private $alerte; The Entity have been generated by using this documentation page : http://symfony.com/doc/current/cookbook/doctrine/reverse_engineering.html In this project I work with 2 databases, and one of it already exist. Working with symfony I use the DQL Query obtain with those methods : EntityRepository.php public function getAllUrl($limit) { $queryBuilder = $ this ->createQueryBuilder('s'); $ this ->setStatsParameters($queryBuilder); $queryBuilder->setMaxResults($limit); return $queryBuilder->getQuery() ->iterate(); } private function setStatsParameters(\Doctrine\ORM\QueryBuilder $queryBuilder) { $queryBuilder->where('s.similitude > 1') ->andWhere('s.url NOT LIKE :url') ->setParameter('url', 'some_string%'); } And here is the stack trace, when the eror comes : stackTrace.log Exception trace: () at \path\to\project\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\ObjectHydrator.php:511 Symfony\Component\Debug\ErrorHandler->handle() at \path\to\project\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\ObjectHydrator.php:511 Doctrine\ORM\Internal\Hydration\ObjectHydrator->hydrateRowData() at \path\to\project\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\AbstractHydrator.php:136 Doctrine\ORM\Internal\Hydration\AbstractHydrator->hydrateRow() at \path\to\project\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\IterableResult.php:76 Doctrine\ORM\Internal\Hydration\IterableResult->next() at \path\to\project\src\Compilatio\RecolteurBundle\Command\RecolteurCommand.php:42 CompanyName\RecolteurBundle\Command\RecolteurCommand->execute() at \path\to\project\vendor\symfony\symfony\src\Symfony\Component\Console\Command\Command.php:244 Symfony\Component\Console\Command\Command->run() at \path\to\project\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:906 Symfony\Component\Console\Application->doRunCommand() at \path\to\project\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:191 Symfony\Component\Console\Application->doRun() at \path\to\project\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Console\Application.php:80 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at \path\to\project\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:121 Symfony\Component\Console\Application->run() at \path\to\project\app\console:27 You can also see here the source code that lead to this error : command.php $sources = $urlLoader->getAllSources(50000); $number = 0; while (($source = $sources->next()) !== false ) { $number++; } echo 'Nombre de sources : ' . $number; There are all the information you ask, if you need more just tell me. For now i can see how to be more specific. Remember that if I switch the hydrator to Query::HYDRATE_SIMPLEOBJECT it solve the bug. I hope all of this will help. Regards, Johanny

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Johanny Clerc-Renaud
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: