Skip to content

Commit

Permalink
Fix issue when using notify tracking policy with multiple flush on en…
Browse files Browse the repository at this point in the history
…tity
  • Loading branch information
xhuberty committed Dec 29, 2015
1 parent 3ca6828 commit f0d15df
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions lib/Doctrine/ORM/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,17 +418,39 @@ public function commit($entity = null)

$this->dispatchPostFlushEvent();

$this->postCommitClear($entity);
}

/**
* @param null|object|array $entity
*/
private function postCommitClear($entity = null) {

// Clear up
$this->entityInsertions =
$this->entityUpdates =
$this->entityDeletions =
$this->extraUpdates =
$this->entityChangeSets =
$this->collectionUpdates =
$this->collectionDeletions =
$this->visitedCollections =
$this->scheduledForSynchronization =
$this->orphanRemovals = array();

if ($entity === null) {
$this->entityChangeSets = $this->scheduledForSynchronization = array();
} elseif (is_object($entity)) {
$oid = spl_object_hash($entity);
$class = $this->em->getClassMetadata(get_class($entity));
$this->clearEntityChangeSet($oid);
$this->clearScheduledForSynchronization($class, $oid);
} elseif (is_array($entity)) {
foreach ($entity as $object) {
$oid = spl_object_hash($object);
$class = $this->em->getClassMetadata(get_class($object));
$this->clearEntityChangeSet($oid);
$this->clearScheduledForSynchronization($class, $oid);
}
}
}

/**
Expand Down Expand Up @@ -3111,7 +3133,19 @@ public function registerManaged($entity, array $id, array $data)
*/
public function clearEntityChangeSet($oid)
{
$this->entityChangeSets[$oid] = array();
if (isset($this->entityChangeSets[$oid])) {
unset($this->entityChangeSets[$oid]);
}
}

/**
* @param $class
* @param string $oid
*/
public function clearScheduledForSynchronization($class, $oid) {
if (isset($this->scheduledForSynchronization[$class->rootEntityName][$oid])) {
unset($this->scheduledForSynchronization[$class->rootEntityName][$oid]);
}
}

/* PropertyChangedListener implementation */
Expand Down

0 comments on commit f0d15df

Please sign in to comment.