Commit a57bc046 authored by webchick's avatar webchick

Issue #2451363 by alexpott, Berdir, pjcdawkins: Ensure install_profile is...

Issue #2451363 by alexpott, Berdir, pjcdawkins: Ensure install_profile is exists in settings.php after installation
parent 4112ca13
......@@ -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);
}
}
<?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'));
}
}
......@@ -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.');
}
}
......@@ -255,6 +255,18 @@
* @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.
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment