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
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
Comment #4
larowlanFixed, thanks, cutting a new release tag
Comment #6
larowlanhttps://www.drupal.org/project/dbal/releases/2.0.3