Skip to content

Commit c4cdfc7

Browse files
committed
fix transaction problems on closure transaction
1 parent 7681795 commit c4cdfc7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Illuminate/Database/Concerns/ManagesTransactions.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,25 @@ public function transaction(Closure $callback, $attempts = 1)
4545
}
4646

4747
try {
48-
$this->commit();
48+
if ($this->transactions == 1) {
49+
$this->getPdo()->commit();
50+
}
51+
52+
$this->transactions = max(0, $this->transactions - 1);
4953
} catch (Exception $e) {
54+
$commitFailed = true;
55+
5056
$this->handleCommitTransactionException(
5157
$e, $currentAttempt, $attempts
5258
);
5359

5460
continue;
5561
}
5662

63+
if (! isset($commitFailed)) {
64+
$this->fireConnectionEvent('committed');
65+
}
66+
5767
return $callbackResult;
5868
}
5969
}

0 commit comments

Comments
 (0)