You are here

protected function Connection::doCommit in Drupal 10

1 call to Connection::doCommit()
Connection::popCommittableTransactions in core/modules/mysql/src/Driver/Database/mysql/Connection.php
Overridden to work around issues to MySQL not supporting transactional DDL.

File

core/modules/mysql/src/Driver/Database/mysql/Connection.php, line 432

Class

Connection
MySQL implementation of \Drupal\Core\Database\Connection.

Namespace

Drupal\mysql\Driver\Database\mysql

Code

protected function doCommit() {

  // MySQL will automatically commit transactions when tables are altered or
  // created (DDL transactions are not supported). Prevent triggering an
  // exception in this case as all statements have been committed.
  if ($this->connection
    ->inTransaction()) {

    // On PHP 7 $this->connection->inTransaction() will return TRUE and
    // $this->connection->commit() does not throw an exception.
    $success = parent::doCommit();
  }
  else {

    // Process the post-root (non-nested) transaction commit callbacks. The
    // following code is copied from
    // \Drupal\Core\Database\Connection::doCommit()
    $success = TRUE;
    if (!empty($this->rootTransactionEndCallbacks)) {
      $callbacks = $this->rootTransactionEndCallbacks;
      $this->rootTransactionEndCallbacks = [];
      foreach ($callbacks as $callback) {
        call_user_func($callback, $success);
      }
    }
  }
  return $success;
}