Skip to content
This repository has been archived by the owner on Oct 8, 2023. It is now read-only.

Commit

Permalink
VI
Browse files Browse the repository at this point in the history
  • Loading branch information
mondrake committed Aug 30, 2023
1 parent 2af9e2c commit 27871e6
Showing 1 changed file with 3 additions and 61 deletions.
64 changes: 3 additions & 61 deletions src/Driver/Database/mysqli/TransactionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,73 +36,15 @@ protected function releaseClientSavepoint(string $name): bool {
/**
* {@inheritdoc}
*/
protected function processRootCommit(): void {
if (!$this->connection->inTransaction()) {
$this->setConnectionTransactionState(ClientConnectionTransactionState::Voided);
$this->processPostTransactionCallbacks();
return;
}
parent::processRootCommit();
}

/**
* {@inheritdoc}
*/
protected function rollbackClientSavepoint(string $name): bool {
if (!$this->connection->inTransaction()) {
$this->resetStack();
$this->setConnectionTransactionState(ClientConnectionTransactionState::Voided);
$this->processPostTransactionCallbacks();
return TRUE;
}
return parent::rollbackClientSavepoint($name);
}

/**
* {@inheritdoc}
*/
protected function releaseClientSavepoint(string $name): bool {
if (!$this->connection->inTransaction()) {
$this->resetStack();
$this->setConnectionTransactionState(ClientConnectionTransactionState::Voided);
$this->processPostTransactionCallbacks();
return TRUE;
}
return parent::releaseClientSavepoint($name);
protected function rollbackClientTransaction(): bool {
return $this->connection->getClientConnection()->rollback();
}

/**
* {@inheritdoc}
*/
protected function commitClientTransaction(): bool {
if (!$this->connection->inTransaction()) {
$this->setConnectionTransactionState(ClientConnectionTransactionState::Voided);
$this->processPostTransactionCallbacks();
return TRUE;
}
$clientCommit = $this->connection->getClientConnection()->commit();
$this->setConnectionTransactionState($clientCommit ?
ClientConnectionTransactionState::Committed :
ClientConnectionTransactionState::CommitFailed
);
return $clientCommit;
}

/**
* {@inheritdoc}
*/
protected function rollbackClientTransaction(): bool {
if (!$this->connection->inTransaction()) {
$this->setConnectionTransactionState(ClientConnectionTransactionState::Voided);
$this->processPostTransactionCallbacks();
trigger_error('Rollback attempted when there is no active transaction. This can cause data integrity issues.', E_USER_WARNING);
}
$clientRollback = $this->connection->getClientConnection()->rollback();
$this->setConnectionTransactionState($clientRollback ?
ClientConnectionTransactionState::RolledBack :
ClientConnectionTransactionState::RollbackFailed
);
return $clientRollback;
return $this->connection->getClientConnection()->commit();
}

}

0 comments on commit 27871e6

Please sign in to comment.