Skip to content

Commit

Permalink
do not rollback savepoints
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Oct 3, 2023
1 parent 1a915b2 commit eb41898
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions demos/init-db.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ protected function isAllowDbModifications(): bool

public function atomic(\Closure $fx)
{
$eRollback = new \Exception('Prevent modification');
$eRollback = !$this->getModel(true)->getPersistence()->getConnection()->inTransaction()
? new \Exception('Prevent modification')
: null;
$res = null;
try {
parent::atomic(function () use ($fx, $eRollback, &$res) {
$res = $fx();

if (!$this->isAllowDbModifications()) {
if ($eRollback !== null && !$this->isAllowDbModifications()) {
throw $eRollback;
}
});
Expand Down

0 comments on commit eb41898

Please sign in to comment.