public function Connection::rollBack in Drupal 9
Same name in this branch
- 9 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::rollBack()
- 9 core/lib/Drupal/Core/Database/Driver/mysql/Connection.php \Drupal\Core\Database\Driver\mysql\Connection::rollBack()
Rolls back the transaction entirely or to a named savepoint.
This method throws an exception if no transaction is active.
Parameters
string $savepoint_name: (optional) The name of the savepoint. The default, 'drupal_transaction', will roll the entire transaction back.
Throws
\Drupal\Core\Database\TransactionOutOfOrderException
\Drupal\Core\Database\TransactionNoActiveException
Overrides Connection::rollBack
See also
\Drupal\Core\Database\Transaction::rollBack()
File
- core/
lib/ Drupal/ Core/ Database/ Driver/ mysql/ Connection.php, line 436
Class
- Connection
- MySQL implementation of \Drupal\Core\Database\Connection.
Namespace
Drupal\Core\Database\Driver\mysqlCode
public function rollBack($savepoint_name = 'drupal_transaction') {
// MySQL will automatically commit transactions when tables are altered or
// created (DDL transactions are not supported). Prevent triggering an
// exception to ensure that the error that has caused the rollback is
// properly reported.
if (!$this->connection
->inTransaction()) {
// On PHP 7 $this->connection->inTransaction() will return TRUE and
// $this->connection->rollback() does not throw an exception; the
// following code is unreachable.
// If \Drupal\Core\Database\Connection::rollBack() would throw an
// exception then continue to throw an exception.
if (!$this
->inTransaction()) {
throw new TransactionNoActiveException();
}
// A previous rollback to an earlier savepoint may mean that the savepoint
// in question has already been accidentally committed.
if (!isset($this->transactionLayers[$savepoint_name])) {
throw new TransactionNoActiveException();
}
trigger_error('Rollback attempted when there is no active transaction. This can cause data integrity issues.', E_USER_WARNING);
return;
}
return parent::rollBack($savepoint_name);
}