From eb4189830f58ba2bec2cbe648d3deffdde38b16b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Tue, 3 Oct 2023 09:25:19 +0200 Subject: [PATCH] do not rollback savepoints --- demos/init-db.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/demos/init-db.php b/demos/init-db.php index 5b87842b76..519d04cd32 100644 --- a/demos/init-db.php +++ b/demos/init-db.php @@ -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; } });