diff --git a/CHANGELOG.md b/CHANGELOG.md index 975e2528..d4d9c990 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ -# v6.1.1 (Not Released Yet) +# v6.1.2 (2024-01-16) + +Fixed +- Fixed an error when rolling back a transaction that did not execute begin (#166) + +# v6.1.1 (2023-12-11) Fixed - Bug where auth and session pool writing to the same file may cause race condition (#152) diff --git a/src/Concerns/ManagesTransactions.php b/src/Concerns/ManagesTransactions.php index 368245a9..a79a602b 100644 --- a/src/Concerns/ManagesTransactions.php +++ b/src/Concerns/ManagesTransactions.php @@ -168,7 +168,7 @@ protected function performRollBack($toLevel) if ($this->currentTransaction !== null) { try { - if ($this->currentTransaction->state() === Transaction::STATE_ACTIVE) { + if ($this->currentTransaction->state() === Transaction::STATE_ACTIVE && $this->currentTransaction->id() !== null) { $this->currentTransaction->rollBack(); } } finally { diff --git a/tests/SessionNotFoundTest.php b/tests/SessionNotFoundTest.php index af2859f6..089993bd 100644 --- a/tests/SessionNotFoundTest.php +++ b/tests/SessionNotFoundTest.php @@ -160,13 +160,13 @@ public function test_session_not_found_on_cursor(): void $passes = 0; $conn->transaction(function () use ($conn, &$passes) { - $cursor = $conn->cursor('SELECT 12345'); - if ($passes === 0) { $this->deleteSession($conn); $passes++; } + $cursor = $conn->cursor('SELECT 12345'); + $this->assertEquals([12345], $cursor->current()); $passes++;