1
0
mirror of synced 2025-01-18 22:41:43 +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->entityUpdates ||
$this->collectionUpdates ||
$this->collectionDeletions ||
$this->orphanRemovals)) {
return; // Nothing to do.
}
$this->orphanRemovals;
if ($this->orphanRemovals) {
if ($anythingToDo && $this->orphanRemovals) {
foreach ($this->orphanRemovals as $orphan) {
$this->remove($orphan);
}
@ -301,6 +300,7 @@ class UnitOfWork implements PropertyChangedListener
$this->evm->dispatchEvent(Events::onFlush, new Event\OnFlushEventArgs($this->em));
}
if ($anythingToDo) {
// Now we need a commit order to maintain referential integrity
$commitOrder = $this->getCommitOrder();
@ -353,6 +353,7 @@ class UnitOfWork implements PropertyChangedListener
foreach ($this->visitedCollections as $coll) {
$coll->takeSnapshot();
}
}
// Raise postFlush
if ($this->evm->hasListeners(Events::postFlush)) {