- Two entities in one-to-many relation (
AuthorandBookin this example) - This is where the bug manifests itself: The „many” side of the relation has a many-to-one relation to a yet another entity (
Book::$ownertoUser) - The aforementioned relation is eagerly loaded (
src/User.php:21) - Another, unrelated entity has a same many-to-one relation (
Account::$usertoUser). As far as I understand the bug, this is only required, so we get a proxy of the entity instead of the entity itself.
- There is one of each entity in the database. The bug manifests itself during hydration
- We fetch the
Bookentity using a non-pk field (Book::$isbn) - We fetch the
Account(container) class to get theUserentity as a proxy - We assign the user entity to a previously empty
User::$ownerfield - We fetch the
Author::$bookscollection, and hydrate it (toArray())
Book::$ownerfield is set to the previously usedUserproxy class
Book::$owneris empty
The field is overwritten in: vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php:450