Problem/Motivation

Drupal\dbal\ConnectionFactory does not include init_commands. In some hosting environments, such as Acquia, default variables cannot be overridden globally and need to be set per session via init_commands, as described here for changing the transaction_isolation variable from REPEATABLE-READ to READ-COMMITTED.

Steps to reproduce

Set init_commands in settings.php to change a variable, such as transaction_isolation, and run drush ev 'print_r(\Drupal::service("dbal_connection")->executeQuery("SHOW VARIABLES;")->fetchAll());' | grep -C2 _isolation to check the value. Currently, only the default database variable will be returned.

Proposed resolution

Include init_commands after getting the connection:

      if (isset($info['init_commands'])) {
        foreach ($info['init_commands'] as $sql) {
          $this->cache[$target]->executeStatement($sql);
        }
      }

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork dbal-3555065

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

thomas.fleming created an issue. See original summary.

larowlan’s picture

Status: Active » Fixed

Fixed, thanks, cutting a new release tag

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

larowlan’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.