Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1129

UnitOfWork consider version field changed as entity changed

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Git Master
    • Fix Version/s: 2.0.5
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      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 +448,9 @@
                   $changeSet = $isChangeTrackingNotify ? $this->entityChangeSets[$oid] : array();
       
                   foreach ($actualData as $propName => $actualValue) {
      +                if ($class->isVersioned && $propName == $class->versionField) {
      +                    continue;
      +                }
                       $orgValue = isset($originalData[$propName]) ? $originalData[$propName] : null;
                       if (isset($class->associationMappings[$propName])) {
                           $assoc = $class->associationMappings[$propName];
      

        Activity

        Hide
        Benjamin Eberlei added a comment -

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

        Show
        Benjamin Eberlei added a comment - The fix is bad. There is a much better way, but i can confirm this issue exists.
        Hide
        Benjamin Eberlei added a comment -

        Fixed.

        Show
        Benjamin Eberlei added a comment - Fixed.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Konstantin
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: