Skip to content

Commit 6207355

Browse files
Jake BarnbyJake Barnby
authored andcommitted
Reset counter on reconnect or rollback failure
1 parent 4bbd108 commit 6207355

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Database/Adapter/SQL.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,11 @@ public function commitTransaction(): bool
8888
{
8989
if ($this->inTransaction === 0) {
9090
return false;
91-
} elseif ($this->inTransaction > 1) {
92-
$this->inTransaction--;
93-
return true;
9491
}
9592

96-
if (!$this->getPDO()->inTransaction()) {
97-
$this->inTransaction = 0;
98-
return false;
93+
if ($this->inTransaction > 1) {
94+
$this->inTransaction--;
95+
return true;
9996
}
10097

10198
try {
@@ -130,6 +127,7 @@ public function rollbackTransaction(): bool
130127
$this->inTransaction = 0;
131128
}
132129
} catch (PDOException $e) {
130+
$this->inTransaction = 0;
133131
throw new DatabaseException('Failed to rollback transaction: ' . $e->getMessage(), $e->getCode(), $e);
134132
}
135133

@@ -153,6 +151,7 @@ public function ping(): bool
153151
public function reconnect(): void
154152
{
155153
$this->getPDO()->reconnect();
154+
$this->inTransaction = 0;
156155
}
157156

158157
/**

0 commit comments

Comments
 (0)