From ba112d975498b7a9c35028edb8b08ecb0d1d527e Mon Sep 17 00:00:00 2001 From: Mohamed Said Date: Tue, 6 Apr 2021 16:48:21 +0200 Subject: [PATCH] call transaction callbacks after updating the transaction levels --- src/Illuminate/Database/Concerns/ManagesTransactions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Database/Concerns/ManagesTransactions.php b/src/Illuminate/Database/Concerns/ManagesTransactions.php index d37c4a3dfb96..98ce50b7668b 100644 --- a/src/Illuminate/Database/Concerns/ManagesTransactions.php +++ b/src/Illuminate/Database/Concerns/ManagesTransactions.php @@ -41,13 +41,13 @@ public function transaction(Closure $callback, $attempts = 1) } try { - if ($this->transactions == 1) { + $this->transactions = max(0, $this->transactions - 1); + + if ($this->transactions == 0) { $this->getPdo()->commit(); optional($this->transactionsManager)->commit($this->getName()); } - - $this->transactions = max(0, $this->transactions - 1); } catch (Throwable $e) { $this->handleCommitTransactionException( $e, $currentAttempt, $attempts