1
0
mirror of synced 2025-01-19 06:51:40 +03:00

Ensure onFlush and postFlush events are always raised

This commit is contained in:
Francesc Rosàs 2012-07-11 00:21:13 +02:00 committed by Benjamin Eberlei
parent ce290bc99b
commit 9322ca7052

View File

@ -281,16 +281,15 @@ class UnitOfWork implements PropertyChangedListener
} }
} }
if ( ! ($this->entityInsertions || $anythingToDo =
$this->entityInsertions ||
$this->entityDeletions || $this->entityDeletions ||
$this->entityUpdates || $this->entityUpdates ||
$this->collectionUpdates || $this->collectionUpdates ||
$this->collectionDeletions || $this->collectionDeletions ||
$this->orphanRemovals)) { $this->orphanRemovals;
return; // Nothing to do.
}
if ($this->orphanRemovals) { if ($anythingToDo && $this->orphanRemovals) {
foreach ($this->orphanRemovals as $orphan) { foreach ($this->orphanRemovals as $orphan) {
$this->remove($orphan); $this->remove($orphan);
} }
@ -301,6 +300,7 @@ class UnitOfWork implements PropertyChangedListener
$this->evm->dispatchEvent(Events::onFlush, new Event\OnFlushEventArgs($this->em)); $this->evm->dispatchEvent(Events::onFlush, new Event\OnFlushEventArgs($this->em));
} }
if ($anythingToDo) {
// Now we need a commit order to maintain referential integrity // Now we need a commit order to maintain referential integrity
$commitOrder = $this->getCommitOrder(); $commitOrder = $this->getCommitOrder();
@ -353,6 +353,7 @@ class UnitOfWork implements PropertyChangedListener
foreach ($this->visitedCollections as $coll) { foreach ($this->visitedCollections as $coll) {
$coll->takeSnapshot(); $coll->takeSnapshot();
} }
}
// Raise postFlush // Raise postFlush
if ($this->evm->hasListeners(Events::postFlush)) { if ($this->evm->hasListeners(Events::postFlush)) {