Skip to content

Commit 40ef8f9

Browse files
halniquetaka-oyama
authored andcommitted
fix: fixed an error when rolling back a transaction that did not execute 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
1 parent ab974df commit 40ef8f9

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# v6.1.1 (Not Released Yet)
1+
# v6.1.2 (2024-01-16)
2+
3+
Fixed
4+
- Fixed an error when rolling back a transaction that did not execute begin (#166)
5+
6+
# v6.1.1 (2023-12-11)
27

38
Fixed
49
- Bug where auth and session pool writing to the same file may cause race condition (#152)

src/Concerns/ManagesTransactions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ protected function performRollBack($toLevel)
168168

169169
if ($this->currentTransaction !== null) {
170170
try {
171-
if ($this->currentTransaction->state() === Transaction::STATE_ACTIVE) {
171+
if ($this->currentTransaction->state() === Transaction::STATE_ACTIVE && $this->currentTransaction->id() !== null) {
172172
$this->currentTransaction->rollBack();
173173
}
174174
} finally {

tests/SessionNotFoundTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,13 @@ public function test_session_not_found_on_cursor(): void
160160
$passes = 0;
161161

162162
$conn->transaction(function () use ($conn, &$passes) {
163-
$cursor = $conn->cursor('SELECT 12345');
164-
165163
if ($passes === 0) {
166164
$this->deleteSession($conn);
167165
$passes++;
168166
}
169167

168+
$cursor = $conn->cursor('SELECT 12345');
169+
170170
$this->assertEquals([12345], $cursor->current());
171171

172172
$passes++;

0 commit comments

Comments
 (0)