DDC-3933: Object string conversion failure when merging detached primary foreign key entity #4811

Open
opened 2026-01-22 14:49:51 +01:00 by admin · 0 comments
Owner

Originally created by @doctrinebot on GitHub (Oct 4, 2015).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user ehimen:

When merging an entity which is the inverse side of a relationship where the owning entity has a primary foreign key, we get an error:

PHPUnit*Framework*Error: Object of class Doctrine\Tests\ORM\Functional\Ticket\DDC3933User could not be converted to string

.../lib/Doctrine/ORM/UnitOfWork.php:1413
.../lib/Doctrine/ORM/UnitOfWork.php:3102
.../lib/Doctrine/ORM/UnitOfWork.php:3411
.../lib/Doctrine/ORM/UnitOfWork.php:1891
.../lib/Doctrine/ORM/UnitOfWork.php:1790
.../lib/Doctrine/ORM/EntityManager.php:667
.../tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3933Test.php:26

This looks to be because the entity itself is passed in as the ID in to \Doctrine\ORM\UnitOfWork::registerManaged in \Doctrine\ORM\UnitOfWork::mergeEntityStateIntoManagedCopy.

Originally created by @doctrinebot on GitHub (Oct 4, 2015). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user ehimen: When merging an entity which is the inverse side of a relationship where the owning entity has a primary foreign key, we get an error: ``` PHPUnit*Framework*Error: Object of class Doctrine\Tests\ORM\Functional\Ticket\DDC3933User could not be converted to string .../lib/Doctrine/ORM/UnitOfWork.php:1413 .../lib/Doctrine/ORM/UnitOfWork.php:3102 .../lib/Doctrine/ORM/UnitOfWork.php:3411 .../lib/Doctrine/ORM/UnitOfWork.php:1891 .../lib/Doctrine/ORM/UnitOfWork.php:1790 .../lib/Doctrine/ORM/EntityManager.php:667 .../tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3933Test.php:26 ``` This looks to be because the entity itself is passed in as the ID in to `\Doctrine\ORM\UnitOfWork::registerManaged` in `\Doctrine\ORM\UnitOfWork::mergeEntityStateIntoManagedCopy`.
admin added the Bug label 2026-01-22 14:49:51 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4811