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

frankcarey created an issue. See original summary.

claudiu.cristea’s picture

Version: 8.0.0-rc1 » 8.0.x-dev
Priority: Normal » Major
Issue tags: +rc target triage

I think that this needs to go in 8.0.0 because it breaks those installations where settings.php is 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.

xjm’s picture

Issue tags: -rc target triage

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

frankcarey’s picture

Status: Active » Closed (cannot reproduce)

This 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