diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php b/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php index e1b56162c9..d5f253880c 100644 --- a/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php +++ b/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php @@ -386,14 +386,7 @@ protected function popCommittableTransactions() { // If there are no more layers left then we should commit. unset($this->transactionLayers[$name]); if (empty($this->transactionLayers)) { - try { - $this->doCommit(); - } - catch (\Exception $e) { - if ($e->getMessage() !== 'There is no active transaction') { - throw $e; - } - } + $this->doCommit(); } else { // Attempt to release this savepoint in the standard way. @@ -412,11 +405,9 @@ protected function popCommittableTransactions() { // If one SAVEPOINT was released automatically, then all were. // Therefore, clean the transaction stack. $this->transactionLayers = []; - if (PHP_VERSION_ID < 80000) { - // We also have to explain to PDO that the transaction stack has - // been cleaned-up. - $this->doCommit(); - } + // We also have to explain to PDO that the transaction stack has + // been cleaned-up. + $this->doCommit(); } else { throw $e; @@ -426,6 +417,46 @@ protected function popCommittableTransactions() { } } + /** + * {@inheritdoc} + */ + public function rollBack($savepoint_name = 'drupal_transaction') { + try { + return parent::rollBack($savepoint_name); + } + catch (\PdoException $e) { + // @todo + if ($e->getMessage() !== 'There is no active transaction') { + throw $e; + } + } + return FALSE; + } + + /** + * {@inheritdoc} + */ + protected function doCommit() { + try { + $success = parent::doCommit(); + } + catch (\PdoException $e) { + // @todo + if ($e->getMessage() !== 'There is no active transaction') { + throw $e; + } + $success = TRUE; + if (!empty($this->rootTransactionEndCallbacks)) { + $callbacks = $this->rootTransactionEndCallbacks; + $this->rootTransactionEndCallbacks = []; + foreach ($callbacks as $callback) { + call_user_func($callback, $success); + } + } + } + return $success; + } + }