Skip to content

Commit ab3596b

Browse files
authored
keep the counter (#36892)
1 parent 103261a commit ab3596b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Illuminate/Database/Concerns/ManagesTransactions.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@ public function transaction(Closure $callback, $attempts = 1)
4141
}
4242

4343
try {
44+
if ($this->transactions == 1) {
45+
$this->getPdo()->commit();
46+
}
47+
4448
$this->transactions = max(0, $this->transactions - 1);
4549

4650
if ($this->transactions == 0) {
47-
$this->getPdo()->commit();
48-
4951
optional($this->transactionsManager)->commit($this->getName());
5052
}
5153
} catch (Throwable $e) {
@@ -187,12 +189,14 @@ public function commit()
187189
{
188190
if ($this->transactions == 1) {
189191
$this->getPdo()->commit();
190-
191-
optional($this->transactionsManager)->commit($this->getName());
192192
}
193193

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

196+
if ($this->transactions == 0) {
197+
optional($this->transactionsManager)->commit($this->getName());
198+
}
199+
196200
$this->fireConnectionEvent('committed');
197201
}
198202

0 commit comments

Comments
 (0)