From 55972218ceb6367f4df81c8c6ae2e71a7c0f557b Mon Sep 17 00:00:00 2001 From: Maciej Malarz Date: Sun, 7 Jan 2018 22:35:28 +0100 Subject: [PATCH] Disallow nested commits --- lib/Doctrine/ODM/MongoDB/MongoDBException.php | 5 +++++ lib/Doctrine/ODM/MongoDB/UnitOfWork.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ODM/MongoDB/MongoDBException.php b/lib/Doctrine/ODM/MongoDB/MongoDBException.php index c4abf35188..0c65b3ee70 100644 --- a/lib/Doctrine/ODM/MongoDB/MongoDBException.php +++ b/lib/Doctrine/ODM/MongoDB/MongoDBException.php @@ -159,4 +159,9 @@ public static function failedToEnsureDocumentSharding($className, $errorMessage) $errorMessage )); } + + public static function commitInProgress() + { + return new self('There is already a commit operation in progress'); + } } diff --git a/lib/Doctrine/ODM/MongoDB/UnitOfWork.php b/lib/Doctrine/ODM/MongoDB/UnitOfWork.php index 12926cac5c..0d4daffa16 100644 --- a/lib/Doctrine/ODM/MongoDB/UnitOfWork.php +++ b/lib/Doctrine/ODM/MongoDB/UnitOfWork.php @@ -394,7 +394,7 @@ public function commit($document = null, array $options = array()) $this->commitsInProgress++; if ($this->commitsInProgress > 1) { - @trigger_error('There is already a commit operation in progress. Calling flush in an event subscriber is deprecated and will be forbidden in 2.0.', E_USER_DEPRECATED); + throw MongoDBException::commitInProgress(); } try { if ($this->orphanRemovals) {