Commit a1d4b162 authored by catch's avatar catch
Browse files

Issue #2278971 by mondrake, daffie, xjm, longwave: Deprecate Connection::supportsTransactions()

parent 3614f4d9
Loading
Loading
Loading
Loading
+0 −8
Changes for core/assets/scaffold/files/default.settings.php: 0 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -105,14 +105,6 @@
 * webserver.  For most other drivers, you must specify a
 * username, password, host, and database name.
 *
 * Transaction support is enabled by default for all drivers that support it,
 * including MySQL. To explicitly disable it, set the 'transactions' key to
 * FALSE.
 * Note that some configurations of MySQL, such as the MyISAM engine, don't
 * support it and will proceed silently even if enabled. If you experience
 * transaction related crashes with such configuration, set the 'transactions'
 * key to FALSE.
 *
 * For each database, you may optionally specify multiple "target" databases.
 * A target database allows Drupal to try to send certain queries to a
 * different database if it can but fall back to the default connection if not.
+13 −17
Changes for core/lib/Drupal/Core/Database/Connection.php: 13 added lines, 17 removed lines.
Original line number Diff line number Diff line
@@ -68,13 +68,6 @@ abstract class Connection {
   */
  protected $statementClass = 'Drupal\Core\Database\Statement';

  /**
   * Whether this database connection supports transactions.
   *
   * @var bool
   */
  protected $transactionSupport = TRUE;

  /**
   * Whether this database connection supports transactional DDL.
   *
@@ -198,6 +191,12 @@ abstract class Connection {
   *   - Other driver-specific options.
   */
  public function __construct(\PDO $connection, array $connection_options) {
    // The 'transactions' option is deprecated.
    if (isset($connection_options['transactions'])) {
      @trigger_error('Passing a \'transactions\' connection option to ' . __METHOD__ . ' is deprecated in drupal:9.1.0 and is removed in drupal:10.0.0. All database drivers must support transactions. See https://www.drupal.org/node/2278745', E_USER_DEPRECATED);
      unset($connection_options['transactions']);
    }

    // Initialize and prepare the connection prefix.
    $this->setPrefix(isset($connection_options['prefix']) ? $connection_options['prefix'] : '');

@@ -1216,9 +1215,6 @@ public function startTransaction($name = '') {
   * @see \Drupal\Core\Database\Transaction::rollBack()
   */
  public function rollBack($savepoint_name = 'drupal_transaction') {
    if (!$this->supportsTransactions()) {
      return;
    }
    if (!$this->inTransaction()) {
      throw new TransactionNoActiveException();
    }
@@ -1278,9 +1274,6 @@ public function rollBack($savepoint_name = 'drupal_transaction') {
   * @see \Drupal\Core\Database\Transaction
   */
  public function pushTransaction($name) {
    if (!$this->supportsTransactions()) {
      return;
    }
    if (isset($this->transactionLayers[$name])) {
      throw new TransactionNameNonUniqueException($name . " is already in use.");
    }
@@ -1311,9 +1304,6 @@ public function pushTransaction($name) {
   * @see \Drupal\Core\Database\Transaction
   */
  public function popTransaction($name) {
    if (!$this->supportsTransactions()) {
      return;
    }
    // The transaction has already been committed earlier. There is nothing we
    // need to do. If this transaction was part of an earlier out-of-order
    // rollback, an exception would already have been thrown by
@@ -1494,9 +1484,15 @@ public function clientVersion() {
   *
   * @return bool
   *   TRUE if this connection supports transactions, FALSE otherwise.
   *
   * @deprecated in drupal:9.1.0 and is removed in drupal:10.0.0. All database
   * drivers must support transactions.
   *
   * @see https://www.drupal.org/node/2278745
   */
  public function supportsTransactions() {
    return $this->transactionSupport;
    @trigger_error(__METHOD__ . ' is deprecated in drupal:9.1.0 and is removed in drupal:10.0.0. All database drivers must support transactions. See https://www.drupal.org/node/2278745', E_USER_DEPRECATED);
    return TRUE;
  }

  /**
+0 −15
Changes for core/lib/Drupal/Core/Database/Driver/mysql/Connection.php: 0 added lines, 15 removed lines.
Original line number Diff line number Diff line
@@ -63,21 +63,6 @@ class Connection extends DatabaseConnection {
   */
  const MIN_MAX_ALLOWED_PACKET = 1024;

  /**
   * Constructs a Connection object.
   */
  public function __construct(\PDO $connection, array $connection_options = []) {
    parent::__construct($connection, $connection_options);

    // This driver defaults to transaction support, except if explicitly passed FALSE.
    $this->transactionSupport = !isset($connection_options['transactions']) || ($connection_options['transactions'] !== FALSE);

    // MySQL never supports transactional DDL.
    $this->transactionalDDLSupport = FALSE;

    $this->connectionOptions = $connection_options;
  }

  /**
   * {@inheritdoc}
   */
+5 −9
Changes for core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php: 5 added lines, 9 removed lines.
Original line number Diff line number Diff line
@@ -49,21 +49,17 @@ class Connection extends DatabaseConnection {
    'NOT REGEXP' => ['operator' => '!~*'],
  ];

  /**
   * {@inheritdoc}
   */
  protected $transactionalDDLSupport = TRUE;

  /**
   * Constructs a connection object.
   */
  public function __construct(\PDO $connection, array $connection_options) {
    parent::__construct($connection, $connection_options);

    // This driver defaults to transaction support, except if explicitly passed FALSE.
    $this->transactionSupport = !isset($connection_options['transactions']) || ($connection_options['transactions'] !== FALSE);

    // Transactional DDL is always available in PostgreSQL,
    // but we'll only enable it if standard transactions are.
    $this->transactionalDDLSupport = $this->transactionSupport;

    $this->connectionOptions = $connection_options;

    // Force PostgreSQL to use the UTF-8 character set by default.
    $this->connection->exec("SET NAMES 'UTF8'");

+5 −5
Changes for core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php: 5 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -55,6 +55,11 @@ class Connection extends DatabaseConnection {
   */
  public $tableDropped = FALSE;

  /**
   * {@inheritdoc}
   */
  protected $transactionalDDLSupport = TRUE;

  /**
   * Constructs a \Drupal\Core\Database\Driver\sqlite\Connection object.
   */
@@ -65,11 +70,6 @@ public function __construct(\PDO $connection, array $connection_options) {

    parent::__construct($connection, $connection_options);

    // This driver defaults to transaction support, except if explicitly passed FALSE.
    $this->transactionSupport = $this->transactionalDDLSupport = !isset($connection_options['transactions']) || $connection_options['transactions'] !== FALSE;

    $this->connectionOptions = $connection_options;

    // Attach one database for each registered prefix.
    $prefixes = $this->prefixes;
    foreach ($prefixes as &$prefix) {
Loading