diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index a61630d1f6a..527df55c466 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -373,7 +373,7 @@ public function commit($entity = null) // Entity deletions come last and need to be in reverse commit order if ($this->entityDeletions) { - for ($count = count($commitOrder), $i = $count - 1; $i >= 0; --$i) { + for ($count = count($commitOrder), $i = $count - 1; $i >= 0 && $this->entityDeletions; --$i) { $this->executeDeletions($commitOrder[$i]); } }