DDC-714: Fix of DDC-167 creates FatalError when persisting a new entity #881

Closed
opened 2026-01-22 12:53:40 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Jul 22, 2010).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user mzach:

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.

Originally created by @doctrinebot on GitHub (Jul 22, 2010). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user mzach: The resolution of [DDC-167](http://www.doctrine-project.org/jira/browse/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.
admin added the Bug label 2026-01-22 12:53:40 +01:00
admin closed this issue 2026-01-22 12:53:41 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jul 25, 2010):

Comment created by @beberlei:

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

@doctrinebot commented on GitHub (Jul 25, 2010): Comment created by @beberlei: This bug also leads to about 400 test failures in the Postgres ORM Testsuite :-)
Author
Owner

@doctrinebot commented on GitHub (Jul 25, 2010):

Comment created by @beberlei:

Fixed! Thanks for reporting.

@doctrinebot commented on GitHub (Jul 25, 2010): Comment created by @beberlei: Fixed! Thanks for reporting.
Author
Owner

@doctrinebot commented on GitHub (Jul 25, 2010):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Jul 25, 2010): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Dec 13, 2015):

Imported 1 attachments from Jira into https://gist.github.com/193347de10bd18e8b6de

@doctrinebot commented on GitHub (Dec 13, 2015): Imported 1 attachments from Jira into https://gist.github.com/193347de10bd18e8b6de - [10704_uow.diff](https://gist.github.com/193347de10bd18e8b6de#file-10704_uow-diff)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#881