When reinstalling an existing site (very common process during development), the existing settings for $settings['install_profile'], $databases['default']['default'], and $config_directories are not preserved like they were in d7, creating duplicate entries in settings.php.
I have a settings.php which uses $_ENV variables to setup the database, etc. Running the /core/install.php script or using `drush si --keep-config` script causes the new (duplicate) settings to be appended to the settings.php file.
Before re-installation
$databases['default']['default'] = array (
'database' => getenv('DB_1_ENV_MYSQL_DATABASE'),
'username' => getenv('DB_1_ENV_MYSQL_USER'),
'password' => getenv('DB_1_ENV_MYSQL_PASSWORD'),
'host' => getenv('DB_1_PORT_3306_TCP_ADDR'),
'prefix' => '',
'port' => '3306',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'driver' => 'mysql',
);
$settings['install_profile'] = 'config_installer';
$config_directories = array(
CONFIG_ACTIVE_DIRECTORY => './../config/active',
CONFIG_SYNC_DIRECTORY => './../config/staging',
);
$settings['bootstrap_config_storage'] = array('Drupal\Core\Config\BootstrapConfigStorageFactory', 'getFileStorage');
After reinstallation:
$databases['default']['default'] = array (
'database' => getenv('DB_1_ENV_MYSQL_DATABASE'),
'username' => getenv('DB_1_ENV_MYSQL_USER'),
'password' => getenv('DB_1_ENV_MYSQL_PASSWORD'),
'host' => getenv('DB_1_PORT_3306_TCP_ADDR'),
'prefix' => '',
'port' => '3306',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'driver' => 'mysql',
);
$settings['install_profile'] = 'config_installer';
$config_directories = array(
CONFIG_ACTIVE_DIRECTORY => './../config/active',
CONFIG_SYNC_DIRECTORY => './../config/staging',
);
$settings['bootstrap_config_storage'] = array('Drupal\Core\Config\BootstrapConfigStorageFactory', 'getFileStorage');
$databases['default']['default'] = array (
'database' => 'drupal',
'username' => 'drupal',
'password' => '123',
'prefix' => '',
'host' => '172.17.0.44',
'port' => '3306',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'driver' => 'mysql',
);
$config_directories['sync'] = 'sites/default/files/config_zfa3kMuN2171K6tY5u9A-8eOS0Wk9Uyv00aF7GcP7PTAMfL9-W7T0a4XQMPAfS2nbplbHbNpvA/sync';
Comments
Comment #2
claudiu.cristeaI think that this needs to go in 8.0.0 because it breaks those installations where
settings.phpis kept in Git with DB credentials read from environment variables. I tried to create a CI flow in this way but I got the same behavior. I confirm this bug.Comment #3
xjmComment #6
cilefen commentedComment #7
frankcarey commentedThis doesn't appear to be an issue anymore? At least not with config_installer profile I don't get anything new showing up in my settings.php