diff --git a/composer.lock b/composer.lock index 1cd7dbf08..8ae3ed589 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ab8904fcdff6010338fe9e4d22c977bf", + "content-hash": "551ac82cdacc10d8a41f4ce450865610", "packages": [ { "name": "brick/math", diff --git a/src/Database/Adapter/SQL.php b/src/Database/Adapter/SQL.php index eac1b3ad1..b1efb4f9f 100644 --- a/src/Database/Adapter/SQL.php +++ b/src/Database/Adapter/SQL.php @@ -88,9 +88,6 @@ public function commitTransaction(): bool { if ($this->inTransaction === 0) { return false; - } elseif ($this->inTransaction > 1) { - $this->inTransaction--; - return true; } if (!$this->getPDO()->inTransaction()) { @@ -98,6 +95,11 @@ public function commitTransaction(): bool return false; } + if ($this->inTransaction > 1) { + $this->inTransaction--; + return true; + } + try { $result = $this->getPDO()->commit(); $this->inTransaction = 0; @@ -130,6 +132,7 @@ public function rollbackTransaction(): bool $this->inTransaction = 0; } } catch (PDOException $e) { + $this->inTransaction = 0; throw new DatabaseException('Failed to rollback transaction: ' . $e->getMessage(), $e->getCode(), $e); } @@ -153,6 +156,7 @@ public function ping(): bool public function reconnect(): void { $this->getPDO()->reconnect(); + $this->inTransaction = 0; } /**