Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-714

Fix of DDC-167 creates FatalError when persisting a new entity

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0-BETA3, 2.0-BETA4
    • Fix Version/s: 2.0-BETA3
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None
    • Environment:
      Debian 5 (64bit), Postgresql 8.3, ZendServer 5.0.2, PHP 5.3.2, Doctrine-HEAD

      Description

      The resolution of DDC-167 introduced a new problem in UnitOfWork on line 612 (function persistNew()) as well - when I try to save an entity, I get an Exception from my error handler (who captues php errors):

      ErrorException with Argument 2 passed to Doctrine\ORM\Mapping\ClassMetadata::setIdentifierValues() must be an array, integer given, called in /var/www/svn/cWorld_ZF/branches/devel-trunk/library/Doctrine/ORM/UnitOfWork.php on line 612 and defined
      Backtrace: #0: Doctrine\ORM\Mapping\ClassMetadata->setIdentifierValues at /var/www/svn/cWorld_ZF/branches/devel-trunk/library/Doctrine/ORM/UnitOfWork.php:612
      #1: Doctrine\ORM\UnitOfWork->persistNew at /var/www/svn/cWorld_ZF/branches/devel-trunk/library/Doctrine/ORM/UnitOfWork.php:1247
      #2: Doctrine\ORM\UnitOfWork->doPersist at /var/www/svn/cWorld_ZF/branches/devel-trunk/library/Doctrine/ORM/UnitOfWork.php:1210
      #3: Doctrine\ORM\UnitOfWork->persist at /var/www/svn/cWorld_ZF/branches/devel-trunk/library/Doctrine/ORM/EntityManager.php:438
      

      The relevant code in UoW is:

                  $idValue = $idGen->generate($this->em, $entity);
                  if ( ! $idGen instanceof \Doctrine\ORM\Id\AssignedGenerator) {
                      $this->entityIdentifiers[$oid] = array($class->identifier[0] => $idValue);
                      $class->setIdentifierValues($entity, $idValue);
      

      We're using the SequenceGenerator

      @SequenceGenerator(allocationSize=1,sequenceName="address_id_seq")
      

      which doesn't return an array, so the array typehint fails and generates an error.

      The fix, which worked for me, is attached.

      1. uow.diff
        0.8 kB
        Michael Zach

        Activity

        Hide
        Benjamin Eberlei added a comment -

        This bug also leads to about 400 test failures in the Postgres ORM Testsuite

        Show
        Benjamin Eberlei added a comment - This bug also leads to about 400 test failures in the Postgres ORM Testsuite
        Hide
        Benjamin Eberlei added a comment -

        Fixed! Thanks for reporting.

        Show
        Benjamin Eberlei added a comment - Fixed! Thanks for reporting.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Michael Zach
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: