Inwe added the new $settings array for storing largely static values that only live in settings.php and are generally needed very early in bootstrap, making them inappropriate for the config or state systems. However right now, there is no good way to get those values into settings.php other than manually adding them. This makes issues like upgrade path very difficult, as some of these values existed in the variable system in D7.
In order to make that easier we should add the ability to write these values into drupal_rewrite_settings(). I haven't looked at that function in too much depth so I'm not really sure how hard it is going to be to accomplish this.
The current code dumps whole arrays like
$database = array('default' => array(.... Instead let's dump
$settings['database']['default']['default']['driver'] = 'mysql'; $settings['database']['default']['default']['database'] = 'drupal';
This, in itself is not terribly problematic. However, the comment blocks in settings.php are helpful and we want the settings to stick to those blocks. So if the default contains
$conf['system.performance']['css']['gzip'] = FALSE; and a new TRUE is written for css compression, ideally this row would be replaced. This needs a little complicated code but nothing a small state machine can't handle.
Reviews needed. Tests are being written.
User interface changes
drupal_rewrite_settings() now expects arrays with .value, .required, .comment keys instead of just value, required, comment because otherwise you couldn't dump
$foo['bar']['value'] = 2;. To dump this, do
$settings['bar']['value'] = array( '.value' => 2, '.required' => TRUE, );
Note that while this is an API change the previous was completely undocumented and very likely unused outside of core so while perhaps a change notice is warranted, it's not too important.
PASSED: [[SimpleTest]]: [MySQL] 52,827 pass(es). View
PASSED: [[SimpleTest]]: [MySQL] 52,266 pass(es). View
PASSED: [[SimpleTest]]: [MySQL] 52,225 pass(es). View