Skip to content

Commit

Permalink
fix transaction problems on closure transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jul 24, 2020
1 parent 7681795 commit c4cdfc7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Illuminate/Database/Concerns/ManagesTransactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,25 @@ public function transaction(Closure $callback, $attempts = 1)
}

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

$this->transactions = max(0, $this->transactions - 1);
} catch (Exception $e) {
$commitFailed = true;

$this->handleCommitTransactionException(
$e, $currentAttempt, $attempts
);

continue;
}

if (! isset($commitFailed)) {
$this->fireConnectionEvent('committed');
}

return $callbackResult;
}
}
Expand Down

0 comments on commit c4cdfc7

Please sign in to comment.