mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
BasicEntityPersister::getValues does not work when entity metadata is not loaded before #6482
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ghost on GitHub (Jun 8, 2020).
Bug Report
Detailed info is here https://github.com/theastar/metadata-bug-reproducer, a summary is below.
Summary
There is a mapped superclass entity
Personand its derived entityPersonInmate.Calling
\Doctrine\ORM\EntityRepository::findOneBywith['person' => new PersonInmate()]if metadata forPersonInmateis not yet loaded results in a object-to-int cast and a notice "Object of class App\Entity\PersonInmate could not be converted to int""Current behavior
The problem is that findOneBy depends on the context of the application. If the metadata for an entity is not loaded before findOneBy is called, it will not work.
How to reproduce
See README in https://github.com/theastar/metadata-bug-reproducer.
Expected behavior
\Doctrine\ORM\Persisters\Entity\BasicEntityPersister::getValues(or somewhere in the call chain) should load metadata if it's not yet loaded, like this:@beberlei commented on GitHub (Sep 25, 2020):
There behavior here should probably be aligned with
AbstractQuery::processParameterValue, which is essentially the related logic for processing parameters in DQL/Native queries.@beberlei commented on GitHub (Sep 25, 2020):
Duplicate of #7512