Permalink
Browse files

Merge pull request #130 from uwej711/fix_compute_changeset

Compute a changeset only once and reset after commit
  • Loading branch information...
2 parents 791a663 + 1b45833 commit aea067fd3e18814b8f0f1dfb09908cc30208a8d1 @lsmith77 lsmith77 committed Apr 12, 2012
Showing with 19 additions and 2 deletions.
  1. +19 −2 lib/Doctrine/ODM/PHPCR/UnitOfWork.php
@@ -156,6 +156,11 @@ class UnitOfWork
/**
* @var array
*/
+ private $changesetComputed = array();
+
+ /**
+ * @var array
+ */
private $idGenerators = array();
/**
@@ -818,8 +823,15 @@ private function computeChangeSet(ClassMetadata $class, $document)
return;
}
- $actualData = $this->getDocumentActualData($class, $document);
$oid = spl_object_hash($document);
+
+ if (in_array($oid, $this->changesetComputed)) {
+ return;
+ }
+
+ $this->changesetComputed[] = $oid;
+
+ $actualData = $this->getDocumentActualData($class, $document);
$id = $this->getDocumentId($document);
$isNew = !isset($this->originalData[$oid]);
@@ -1231,7 +1243,9 @@ public function commit($document = null)
$this->scheduledRemovals =
$this->scheduledMoves =
$this->scheduledInserts =
- $this->visitedCollections = array();
+ $this->visitedCollections =
+ $this->documentChangesets =
+ $this->changesetComputed = array();
}
/**
@@ -1734,6 +1748,8 @@ private function unregisterDocument($document)
$this->documentHistory[$oid],
$this->documentVersion[$oid]
);
+
+ $this->changesetComputed = array_diff($this->changesetComputed, array($oid));
}
/**
@@ -1891,6 +1907,7 @@ public function clear()
$this->nonMappedData =
$this->originalData =
$this->documentChangesets =
+ $this->changesetComputed =
$this->scheduledUpdates =
$this->scheduledAssociationUpdates =
$this->scheduledInserts =

0 comments on commit aea067f

Please sign in to comment.