diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index bfe5087..00c301e 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -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); + } +} diff --git a/core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.php b/core/modules/system/src/Tests/Installer/InstallerExistingSettingsNoProfileTest.php similarity index 74% copy from core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.php copy to core/modules/system/src/Tests/Installer/InstallerExistingSettingsNoProfileTest.php index 1951f57..61dd5be 100644 --- a/core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.php +++ b/core/modules/system/src/Tests/Installer/InstallerExistingSettingsNoProfileTest.php @@ -2,26 +2,27 @@ /** * @file - * Contains \Drupal\system\Tests\Installer\InstallerExistingSettingsTest. + * 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. + * Tests the installer with an existing settings file but no install profile. * * @group Installer */ -class InstallerExistingSettingsTest extends InstallerTestBase { +class InstallerExistingSettingsNoProfileTest extends InstallerTestBase { /** * {@inheritdoc} * - * Fully configures a preexisting settings.php file before invoking the - * interactive installer. + * Configures a preexisting settings.php file without an install_profile + * setting before invoking the interactive installer. */ protected function setUp() { // Pre-configure hash salt. @@ -31,15 +32,6 @@ protected function setUp() { '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. - $this->settings['settings']['install_profile'] = (object) array( - 'value' => 'testing', - 'required' => TRUE, - ); - // Pre-configure database credentials. $connection_info = Database::getConnectionInfo(); unset($connection_info['default']['pdo']); @@ -81,6 +73,7 @@ protected function setUpSettings() { public function testInstaller() { $this->assertUrl('user/1'); $this->assertResponse(200); + $this->assertEqual('testing', Settings::get('install_profile')); } } diff --git a/core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.php b/core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.php index 1951f57..25be1ef 100644 --- a/core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.php +++ b/core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.php @@ -31,12 +31,10 @@ protected function setUp() { '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 @@ protected function setUpSettings() { 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.'); } } diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php index effa94d..d4bb0de 100644 --- a/sites/default/default.settings.php +++ b/sites/default/default.settings.php @@ -256,6 +256,18 @@ */ /** + * 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. * * This variable will be set to a random value by the installer. All one-time