Issue #2451363 by alexpott, Berdir, pjcdawkins: Ensure install_profile is exists in settings.php after installation

8.0.x
webchick 2015-04-02 11:32:46 -07:00
parent 4112ca1308
commit a57bc046ff
4 changed files with 114 additions and 5 deletions

View File

@ -730,6 +730,8 @@ function install_tasks($install_state) {
'run' => $install_state['settings_verified'] ? INSTALL_TASK_SKIP : INSTALL_TASK_RUN_IF_NOT_COMPLETED,
'function' => 'Drupal\Core\Installer\Form\SiteSettingsForm',
),
'install_write_profile' => array(
),
'install_verify_database_ready' => array(
'run' => $install_state['database_ready'] ? INSTALL_TASK_SKIP : INSTALL_TASK_RUN_IF_NOT_COMPLETED,
),
@ -2263,3 +2265,20 @@ function install_display_requirements($install_state, $requirements) {
}
}
}
/**
* Installation task; ensures install profile is written to settings.php.
*
* @param array $install_state
* An array of information about the current installation state.
*/
function install_write_profile($install_state) {
if (Settings::get('install_profile') !== $install_state['parameters']['profile']) {
// Remember the profile which was used.
$settings['settings']['install_profile'] = (object) array(
'value' => $install_state['parameters']['profile'],
'required' => TRUE,
);
drupal_rewrite_settings($settings);
}
}

View File

@ -0,0 +1,79 @@
<?php
/**
* @file
* Contains \Drupal\system\Tests\Installer\InstallerExistingSettingsNoProfileTest.
*/
namespace Drupal\system\Tests\Installer;
use Drupal\Core\Site\Settings;
use Drupal\simpletest\InstallerTestBase;
use Drupal\Core\Database\Database;
/**
* Tests the installer with an existing settings file but no install profile.
*
* @group Installer
*/
class InstallerExistingSettingsNoProfileTest extends InstallerTestBase {
/**
* {@inheritdoc}
*
* Configures a preexisting settings.php file without an install_profile
* setting before invoking the interactive installer.
*/
protected function setUp() {
// Pre-configure hash salt.
// Any string is valid, so simply use the class name of this test.
$this->settings['settings']['hash_salt'] = (object) array(
'value' => __CLASS__,
'required' => TRUE,
);
// Pre-configure database credentials.
$connection_info = Database::getConnectionInfo();
unset($connection_info['default']['pdo']);
unset($connection_info['default']['init_commands']);
$this->settings['databases']['default'] = (object) array(
'value' => $connection_info,
'required' => TRUE,
);
// Pre-configure config directories.
$this->settings['config_directories'] = array(
CONFIG_ACTIVE_DIRECTORY => (object) array(
'value' => conf_path() . '/files/config_active',
'required' => TRUE,
),
CONFIG_STAGING_DIRECTORY => (object) array(
'value' => conf_path() . '/files/config_staging',
'required' => TRUE,
),
);
mkdir($this->settings['config_directories'][CONFIG_ACTIVE_DIRECTORY]->value, 0777, TRUE);
mkdir($this->settings['config_directories'][CONFIG_STAGING_DIRECTORY]->value, 0777, TRUE);
parent::setUp();
}
/**
* {@inheritdoc}
*/
protected function setUpSettings() {
// This step should not appear, since settings.php is fully configured
// already.
}
/**
* Verifies that installation succeeded.
*/
public function testInstaller() {
$this->assertUrl('user/1');
$this->assertResponse(200);
$this->assertEqual('testing', Settings::get('install_profile'));
}
}

View File

@ -31,12 +31,10 @@ class InstallerExistingSettingsTest extends InstallerTestBase {
'required' => TRUE,
);
// Actually the install profile should be skipped to because it is written
// to settings.php.
// @todo https://www.drupal.org/node/2451369 Fix install_profile so that it
// is written to an existing settings.php if possible or if set used.
// During interactive install we'll change this to a different profile and
// this test will ensure that the new value is written to settings.php.
$this->settings['settings']['install_profile'] = (object) array(
'value' => 'testing',
'value' => 'minimal',
'required' => TRUE,
);
@ -81,6 +79,7 @@ class InstallerExistingSettingsTest extends InstallerTestBase {
public function testInstaller() {
$this->assertUrl('user/1');
$this->assertResponse(200);
$this->assertEqual('testing', drupal_get_profile(), 'Profile was changed from minimal to testing during interactive install.');
}
}

View File

@ -255,6 +255,18 @@ $config_directories = array();
* @see \Drupal\Core\Site\Settings::get()
*/
/**
* The active installation profile.
*
* Changing this after installation is not recommended as it changes which
* directories are scanned during extension discovery. If this is set prior to
* installation this value will be rewritten according to the profile selected
* by the user.
*
* @see install_select_profile()
*/
# $settings['install_profile'] = '';
/**
* Salt for one-time login links, cancel links, form tokens, etc.
*