Skip to content

Loading…

DDC-1685: Using the CountWalker on an entity with ID on OneToOne field fails #2331

Closed
doctrinebot opened this Issue · 3 comments

2 participants

@doctrinebot

Jira issue originally created by user burgov:

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:

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:

<?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;
    }
}
@doctrinebot

Comment created by @beberlei:

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.

@doctrinebot

Comment created by @beberlei:

Fixed in master.

@doctrinebot

Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.3 milestone
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.