Skip to content

Commit

Permalink
fix: fixed an error when rolling back a transaction that did not exec…
Browse files Browse the repository at this point in the history
…ute begin (#166)

* fix: fixed an error when rolling back a transaction that did not execute begin

* test: fix cursor rollback

* chore: update CHANGELOG

* chore: fill release date
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
halnique authored and taka-oyama committed Jan 23, 2024
1 parent ab974df commit 40ef8f9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Concerns/ManagesTransactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions tests/SessionNotFoundTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down

0 comments on commit 40ef8f9

Please sign in to comment.