Skip to content

Commit

Permalink
keep the counter (#36892)
Browse files Browse the repository at this point in the history
  • Loading branch information
themsaid authored Apr 6, 2021
1 parent 103261a commit ab3596b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Illuminate/Database/Concerns/ManagesTransactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ public function transaction(Closure $callback, $attempts = 1)
}

try {
if ($this->transactions == 1) {
$this->getPdo()->commit();
}

$this->transactions = max(0, $this->transactions - 1);

if ($this->transactions == 0) {
$this->getPdo()->commit();

optional($this->transactionsManager)->commit($this->getName());
}
} catch (Throwable $e) {
Expand Down Expand Up @@ -187,12 +189,14 @@ public function commit()
{
if ($this->transactions == 1) {
$this->getPdo()->commit();

optional($this->transactionsManager)->commit($this->getName());
}

$this->transactions = max(0, $this->transactions - 1);

if ($this->transactions == 0) {
optional($this->transactionsManager)->commit($this->getName());
}

$this->fireConnectionEvent('committed');
}

Expand Down

0 comments on commit ab3596b

Please sign in to comment.