Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 59dadf6

Browse files
committed
[GH-6394] Bugfix: BasicEntityPersister::update used wrong identifiers for version assignment.
1 parent 66a95ea commit 59dadf6

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ public function update($entity)
394394
$this->updateTable($entity, $quotedTableName, $data, $isVersioned);
395395

396396
if ($isVersioned) {
397-
$id = $this->em->getUnitOfWork()->getEntityIdentifier($entity);
397+
$id = $this->class->getIdentifierValues($entity);
398398

399399
$this->assignDefaultVersionValue($entity, $id);
400400
}

lib/Doctrine/ORM/Utility/IdentifierFlattener.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,13 @@ public function flattenIdentifier(ClassMetadata $class, array $id)
7171
$flatId = [];
7272

7373
foreach ($class->identifier as $field) {
74-
if (isset($class->associationMappings[$field]) && isset($id[$field])) {
74+
if (isset($class->associationMappings[$field]) && isset($id[$field]) && is_object($id[$field])) {
7575
/* @var $targetClassMetadata ClassMetadata */
7676
$targetClassMetadata = $this->metadataFactory->getMetadataFor(
7777
$class->associationMappings[$field]['targetEntity']
7878
);
7979

80-
if (!is_object($id[$field])) {
81-
$associatedId = [$id[$field]];
82-
} elseif ($this->unitOfWork->isInIdentityMap($id[$field])) {
80+
if ($this->unitOfWork->isInIdentityMap($id[$field])) {
8381
$associatedId = $this->flattenIdentifier($targetClassMetadata, $this->unitOfWork->getEntityIdentifier($id[$field]));
8482
} else {
8583
$associatedId = $this->flattenIdentifier($targetClassMetadata, $targetClassMetadata->getIdentifierValues($id[$field]));

0 commit comments

Comments
 (0)