1
0
mirror of synced 2025-02-09 08:49:26 +03:00

Disallowing null as part of the entity identifier

This commit is contained in:
Marco Pivetta 2016-07-07 20:29:00 +02:00
parent 2829174267
commit 1cb8d790b6

View File

@ -1398,12 +1398,13 @@ class UnitOfWork implements PropertyChangedListener
public function addToIdentityMap($entity)
{
$classMetadata = $this->em->getClassMetadata(get_class($entity));
$idHash = implode(' ', $this->entityIdentifiers[spl_object_hash($entity)]);
$identifier = $this->entityIdentifiers[spl_object_hash($entity)];
if ($idHash === '') {
if (in_array(null, $identifier, true)) {
throw ORMInvalidArgumentException::entityWithoutIdentity($classMetadata->name, $entity);
}
$idHash = implode(' ', $identifier);
$className = $classMetadata->rootEntityName;
if (isset($this->identityMap[$className][$idHash])) {