DDC-1129: UnitOfWork consider version field changed as entity changed #1727

Closed
doctrinebot opened this Issue Apr 28, 2011 · 3 comments

2 participants

@doctrinebot

Jira issue originally created by user realmfoo:

I use @version field and after first save it thinks that versionField was changed.

$Entity = $em->find(...);
$Entity->changeField();
$em->persist($Entity);
$em->flush();
$em->getUnitOfWork()->computeChangeSets();
var_dump($em->getUnitOfWork()->getEntityChangeSet($Entity);
array(1) {
  ["version"]=>
  array(2) {
    [0]=>
    int(183)
    [1]=>
    int(184)
  }
}

I fixed it in method computeChangeSet on lines around 473:

Index: ../vendor/doctrine/lib/Doctrine/ORM/UnitOfWork.php
===================================================================
@@ -448,6 <ins>448,9 @@
             $changeSet = $isChangeTrackingNotify ? $this->entityChangeSets[$oid] : array();

             foreach ($actualData as $propName => $actualValue) {
</ins>                if ($class->isVersioned && $propName == $class->versionField) {
<ins>                    continue;
</ins>                }
                 $orgValue = isset($originalData[$propName]) ? $originalData[$propName] : null;
                 if (isset($class->associationMappings[$propName])) {
                     $assoc = $class->associationMappings[$propName];
@doctrinebot

Comment created by @beberlei:

The fix is bad. There is a much better way, but i can confirm this issue exists.

@doctrinebot

Comment created by @beberlei:

Fixed.

@doctrinebot

Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added this to the 2.0.5 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment