Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2345

convertObjectParameterToScalarValue() raises a notice

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.4
    • Component/s: ORM
    • Labels:
      None

      Description

      In Doctrine\ORM\AbstractQuery.php, the method convertObjectParameterToScalarValue() can raise a Notice.
      This code:

      $value = $values[$class->getSingleIdentifierFieldName()];
      

      should be changed in this one:

      if (isset($values[$class->getSingleIdentifierFieldName()])) {
          $value = $values[$class->getSingleIdentifierFieldName()];
      }
      

        Activity

        Hide
        Benjamin Eberlei added a comment -

        Fixed in 2.4

        Show
        Benjamin Eberlei added a comment - Fixed in 2.4
        Hide
        Massimiliano Arione added a comment -

        Nope, just a plain "id".

        Show
        Massimiliano Arione added a comment - Nope, just a plain "id".
        Hide
        Marco Pivetta added a comment -

        Massimiliano Arione having a composite primary key?

        Show
        Marco Pivetta added a comment - Massimiliano Arione having a composite primary key?
        Hide
        Massimiliano Arione added a comment -

        Unfortunately, I'm not really a Doctrine guru.
        I can tell you that I'm getting that notice, using Sortable behavior with Symfony2.
        This is a partial error stack:

        1 in (...)/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php at line 282
        
        2 at ErrorHandler ->handle ('8', 'Undefined index: id', '(...)/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php', '282', array('value' => object(MyEntity), 'class' => object(ClassMetadata), 'values' => array()))
        
        3 in (...)/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php at line 282
        at AbstractQuery ->convertObjectParameterToScalarValue (object(MyEntity))
        
        4 in (...)/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php at line 260
        at AbstractQuery ->processParameterValue (object(MyEntity))
        
        5 in (...)/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php at line 285
        at Query ->processParameterMappings (array('group__1' => array('0')))
        
        6 in (...)/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php at line 258
        at Query ->_doExecute ()
        
        7 in (...)/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php at line 737
        at AbstractQuery ->execute (null, '1')
        
        8 in (...)/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php at line 538
        at AbstractQuery ->getResult ()
        
        9 in (...)/vendor/gedmo/doctrine-extensions/lib/Gedmo/Sortable/SortableListener.php at line 410
        at SortableListener ->getMaxPosition (object(EntityManager), object(ClassMetadata), array('position' => 'rank', 'groups' => array('my_entity'), 'useObjectClass' => 'Meeting\GestioneBundle\Entity\MyRelatedEntity'), object(MyRelatedEntity))
        
        10 in (...)/vendor/gedmo/doctrine-extensions/lib/Gedmo/Sortable/SortableListener.php at line 114
        at SortableListener ->prePersist (object(LifecycleEventArgs))
        
        11 in (...)/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php at line 61
        
        Show
        Massimiliano Arione added a comment - Unfortunately, I'm not really a Doctrine guru. I can tell you that I'm getting that notice, using Sortable behavior with Symfony2. This is a partial error stack: 1 in (...)/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php at line 282 2 at ErrorHandler ->handle ('8', 'Undefined index: id', '(...)/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php', '282', array('value' => object(MyEntity), 'class' => object(ClassMetadata), 'values' => array())) 3 in (...)/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php at line 282 at AbstractQuery ->convertObjectParameterToScalarValue (object(MyEntity)) 4 in (...)/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php at line 260 at AbstractQuery ->processParameterValue (object(MyEntity)) 5 in (...)/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php at line 285 at Query ->processParameterMappings (array('group__1' => array('0'))) 6 in (...)/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php at line 258 at Query ->_doExecute () 7 in (...)/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php at line 737 at AbstractQuery ->execute ( null , '1') 8 in (...)/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php at line 538 at AbstractQuery ->getResult () 9 in (...)/vendor/gedmo/doctrine-extensions/lib/Gedmo/Sortable/SortableListener.php at line 410 at SortableListener ->getMaxPosition (object(EntityManager), object(ClassMetadata), array('position' => 'rank', 'groups' => array('my_entity'), 'useObjectClass' => 'Meeting\GestioneBundle\Entity\MyRelatedEntity'), object(MyRelatedEntity)) 10 in (...)/vendor/gedmo/doctrine-extensions/lib/Gedmo/Sortable/SortableListener.php at line 114 at SortableListener ->prePersist (object(LifecycleEventArgs)) 11 in (...)/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php at line 61
        Hide
        Marco Pivetta added a comment -

        Massimiliano Arione the current DQL implementation doesn't allow you to bind composite key identifiers as parameters, thus you will never reach that piece of code.

        A test would be needed for this case.

        Show
        Marco Pivetta added a comment - Massimiliano Arione the current DQL implementation doesn't allow you to bind composite key identifiers as parameters, thus you will never reach that piece of code. A test would be needed for this case.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Massimiliano Arione
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: