[DDC-1685] Using the CountWalker on an entity with ID on OneToOne field fails Created: 06/Mar/12  Updated: 27/May/12  Resolved: 27/May/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: Git Master
Fix Version/s: 2.3
Security Level: All

Type: Bug Priority: Major
Reporter: Bart van den Burg Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

any



 Description   

When using the CountWalker on an entity which has @Id not on a column, but on a @OneToOne property, a fatal error occurs:

Notice: Undefined index: person in D:\workspace9\roompot\vendor\doctrine\lib\Doctrine\ORM\Mapping\ClassMetadataInfo.php line 2301

In this case I'm using the Paginator by KnpLabs. Here is the trace:

Trace
Notice: Undefined index: person in D:\workspace9\roompot\vendor\doctrine\lib\Doctrine\ORM\Mapping\ClassMetadataInfo.php line 2301
500 Internal Server Error - ErrorException

Stack Trace
in D:\workspace9\roompot\vendor\symfony\src\Symfony\Component\HttpKernel\Debug\ErrorHandler.php at line 65   
        }
        if (error_reporting() & $level && $this->level & $level) {
            throw new \ErrorException(sprintf('%s: %s in %s line %d', isset($this->levels[$level]) ? $this->levels[$level] : $level, $message, $file, $line));
        }
        return false;
at ErrorHandler ->handle ('8', 'Undefined index: person', 'D:\workspace9\roompot\vendor\doctrine\lib\Doctrine\ORM\Mapping\ClassMetadataInfo.php', '2301', array('field' => 'person', 'platform' => object(MySqlPlatform))) 
in D:\workspace9\roompot\vendor\doctrine\lib\Doctrine\ORM\Mapping\ClassMetadataInfo.php at line 2301    
at ClassMetadataInfo ->getQuotedColumnName ('person', object(MySqlPlatform)) 
in D:\workspace9\roompot\vendor\doctrine\lib\Doctrine\ORM\Query\SqlWalker.php at line 548    
at SqlWalker ->walkPathExpression (object(PathExpression)) 
in D:\workspace9\roompot\vendor\doctrine\lib\Doctrine\ORM\Query\AST\PathExpression.php at line 56    
at PathExpression ->dispatch (object(SqlWalker)) 
in D:\workspace9\roompot\vendor\doctrine\lib\Doctrine\ORM\Query\SqlWalker.php at line 2126    
at SqlWalker ->walkArithmeticPrimary (object(PathExpression)) 
in D:\workspace9\roompot\vendor\doctrine\lib\Doctrine\ORM\Query\SqlWalker.php at line 2105    
at SqlWalker ->walkArithmeticFactor (object(PathExpression)) 
in D:\workspace9\roompot\vendor\doctrine\lib\Doctrine\ORM\Query\SqlWalker.php at line 2084    
at SqlWalker ->walkArithmeticTerm (object(PathExpression)) 
in D:\workspace9\roompot\vendor\doctrine\lib\Doctrine\ORM\Query\SqlWalker.php at line 2061    
at SqlWalker ->walkSimpleArithmeticExpression (object(PathExpression)) 
in D:\workspace9\roompot\vendor\doctrine\lib\Doctrine\ORM\Query\SqlWalker.php at line 1408    
at SqlWalker ->walkAggregateExpression (object(AggregateExpression)) 
in D:\workspace9\roompot\vendor\doctrine\lib\Doctrine\ORM\Query\AST\AggregateExpression.php at line 50    
at AggregateExpression ->dispatch (object(SqlWalker)) 
in D:\workspace9\roompot\vendor\doctrine\lib\Doctrine\ORM\Query\SqlWalker.php at line 1139    
at SqlWalker ->walkSelectExpression (object(SelectExpression)) 
at array_map (array(object(SqlWalker), 'walkSelectExpression'), array(object(SelectExpression))) 
in D:\workspace9\roompot\vendor\doctrine\lib\Doctrine\ORM\Query\SqlWalker.php at line 596    
at SqlWalker ->walkSelectClause (object(SelectClause)) 
in D:\workspace9\roompot\vendor\doctrine\lib\Doctrine\ORM\Query\SqlWalker.php at line 417    
at SqlWalker ->walkSelectStatement (object(SelectStatement)) 
in D:\workspace9\roompot\vendor\doctrine\lib\Doctrine\ORM\Query\Exec\SingleSelectExecutor.php at line 38    
at SingleSelectExecutor ->__construct (object(SelectStatement), object(SqlWalker)) 
in D:\workspace9\roompot\vendor\doctrine\lib\Doctrine\ORM\Query\SqlWalker.php at line 192    
at SqlWalker ->getExecutor (object(SelectStatement)) 
in D:\workspace9\roompot\vendor\doctrine\lib\Doctrine\ORM\Query\Parser.php at line 325    
at Parser ->parse () 
in D:\workspace9\roompot\vendor\doctrine\lib\Doctrine\ORM\Query.php at line 230    
at Query ->_parse () 
in D:\workspace9\roompot\vendor\doctrine\lib\Doctrine\ORM\Query.php at line 241    
at Query ->_doExecute () 
in D:\workspace9\roompot\vendor\doctrine\lib\Doctrine\ORM\AbstractQuery.php at line 643    
at AbstractQuery ->execute (array(), '2') 
in D:\workspace9\roompot\vendor\doctrine\lib\Doctrine\ORM\AbstractQuery.php at line 468    
at AbstractQuery ->getResult ('2') 
in D:\workspace9\roompot\vendor\knp-components\src\Knp\Component\Pager\Event\Subscriber\Paginate\Doctrine\ORM\QuerySubscriber.php at line 45    
at QuerySubscriber ->items (object(ItemsEvent)) 
at call_user_func (array(object(QuerySubscriber), 'items'), object(ItemsEvent)) 
in D:\workspace9\roompot\vendor\symfony\src\Symfony\Bundle\FrameworkBundle\Debug\TraceableEventDispatcher.php at line 124    
at TraceableEventDispatcher ->doDispatch (array(array(object(QueryBuilderSubscriber), 'items'), array(object(QueryBuilderSubscriber), 'items'), array(object(QuerySubscriber), 'items'), array(object(QuerySubscriber), 'items'), array(object(QuerySubscriber), 'items'), array(object(QuerySubscriber), 'items'), array(object(CollectionSubscriber), 'items'), array(object(PropelQuerySubscriber), 'items'), array(object(SolariumQuerySubscriber), 'items'), array(object(ArraySubscriber), 'items')), 'knp_pager.items', object(ItemsEvent)) 
in D:\workspace9\roompot\app\cache\sitwst05_roompot\classes.php at line 3996    
at EventDispatcher ->dispatch ('knp_pager.items', object(ItemsEvent)) 
in D:\workspace9\roompot\app\cache\sitwst05_roompot\classes.php at line 5125    
at ContainerAwareEventDispatcher ->dispatch ('knp_pager.items', object(ItemsEvent)) 
in D:\workspace9\roompot\vendor\symfony\src\Symfony\Bundle\FrameworkBundle\Debug\TraceableEventDispatcher.php at line 72    
at TraceableEventDispatcher ->dispatch ('knp_pager.items', object(ItemsEvent)) 
in D:\workspace9\roompot\vendor\knp-components\src\Knp\Component\Pager\Paginator.php at line 76    
at Paginator ->paginate (object(Query), '1', '25') 
in D:\workspace9\roompot\src\Samson\TRSBundle\Controller\RegistrarController.php at line 34    
at RegistrarController ->indexAction () 
at call_user_func_array (array(object(RegistrarController), 'indexAction'), array()) 
in D:\workspace9\roompot\app\cache\sitwst05_roompot\classes.php at line 4241    
at HttpKernel ->handleRaw (object(Request), '1') 
in D:\workspace9\roompot\app\cache\sitwst05_roompot\classes.php at line 4205    
at HttpKernel ->handle (object(Request), '1', true) 
in D:\workspace9\roompot\app\cache\sitwst05_roompot\classes.php at line 5192    
at HttpKernel ->handle (object(Request), '1', true) 
in D:\workspace9\roompot\app\bootstrap.php.cache at line 564    
at Kernel ->handle (object(Request)) 
in D:\workspace9\roompot\web\app_dev.php at line 30    

And the entity:

Entity
<?php

namespace Samson\TRSBundle\Entity;

use Samson\AddressBookBundle\Entity\Person;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 */
class Registrar
{
    /**
     * @ORM\Id
     * @ORM\OneToOne(targetEntity="Samson\AddressBookBundle\Entity\Person", cascade={"persist"})
     * @ORM\JoinColumn(nullable=false)
     */
    private $person;

    public function getId()
    {
        return $this->person->getId();
    }

    public function getPerson()
    {
        return $this->person;
    }

    public function setPerson($person)
    {
        $this->person = $person;
    }
}


 Comments   
Comment by Benjamin Eberlei [ 27/May/12 ]

This is a bug with the KnpPager. It doent handle this siutation and breaks the DQL => SQL AST. Our own pager throws another exception here, solving that within the scope of that ticket now.

Comment by Benjamin Eberlei [ 27/May/12 ]

Fixed in master.

Generated at Sun Oct 26 00:49:09 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.