Skip to content

Commit

Permalink
Merge pull request #1722 from malarzm/nested-commit-exception
Browse files Browse the repository at this point in the history
[2.0] Disallow nested commits
  • Loading branch information
malarzm authored Jan 9, 2018
2 parents f3468b7 + 324d84b commit adf0b7e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/Doctrine/ODM/MongoDB/MongoDBException.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,12 @@ public static function failedToEnsureDocumentSharding($className, $errorMessage)
$errorMessage
));
}

/**
* @return MongoDBException
*/
public static function commitInProgress()
{
return new self('There is already a commit operation in progress. Did you call flush from an event listener?');
}
}
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/MongoDB/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ public function commit(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) {
Expand Down

0 comments on commit adf0b7e

Please sign in to comment.