function Connection::doCommit

Same name in this branch
  1. 9 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::doCommit()
Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::doCommit()
  2. 10 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::doCommit()

Overrides Connection::doCommit

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 466

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.