-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
Bug Report
| Q | A |
|---|---|
| BC Break | yes |
| Version | 2.6.3 |
Summary
We have a problem with the cache on a high-load project. Several times a day, the entity is retrieved from the cache with the field value = null, and these fields cannot be null
/ **
* @var curator
*
* @ManyToOne (targetEntity = "SD \ Domain \ PersistModel \ Curator \ Curator")
* @JoinColumn (name = "curator_id", referencedColumnName = "id")
* /
private $ curator ;
Current behavior
This situation arises from related entities. When the parent entity gets out of the cache, and the related is already expired.
See DefaultEntityHydrator function loadCacheEntry
Then
BasicEntityPersister function load will return Entity with null fields value.
Because AbstractEntityPersister
$entity = $this->persister->loadById($identifier, $entity);
It put $entity = null to function loadById($identifier, $entity) Instead Entity.
How to reproduce
Set $assocEntry = null on DefaultEntityHydrator line180 for child entity
Expected behavior
I think this can be corrected by editing the code in function loadById(array $identifier, $entity = null)
loadById
Replace $ entity with $ cachedEntity
https://github.com/doctrine/orm/blob/master/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php#L458
$cachedEntity = $this->persister->loadById($identifier, $entity);
if ($cachedEntity === null) {
return null;
}