diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 9c78d68..673648a 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -429,6 +429,11 @@ function conf_path($require_settings = TRUE, $reset = FALSE) { if ($conf && !$reset) { return $conf; } + // Keep the conf_path alive across drupal_static_reset() calls. + if (class_exists('Drupal\\Component\\Utility\\Settings') && ($simpletest_conf_path = settings()->get('simpletest_conf_path'))) { + $conf = $simpletest_conf_path; + return $conf; + } $script_name = $_SERVER['SCRIPT_NAME']; if (!$script_name) { @@ -2604,7 +2609,7 @@ function drupal_valid_test_ua($new_prefix = NULL) { // and the HMAC must match. if ($time_diff >= 0 && $time_diff <= 5 && $hmac == drupal_hmac_base64($check_string, $key)) { $test_prefix = $prefix; - _drupal_test_overrides($test_prefix, $config); + _drupal_load_test_overrides($test_prefix, $config); return $test_prefix; } } @@ -2614,9 +2619,11 @@ function drupal_valid_test_ua($new_prefix = NULL) { } /** + * Overrides some very basic settings. + * * Very strictly for internal use only. * - * Loads override.php and settings.php from the simpletest public files + * Loads settings.php from the simpletest public files * directory. These files can change the global $conf, the global * $config_directories, the return value of conf_path() and * settings(). @@ -2628,7 +2635,7 @@ function drupal_valid_test_ua($new_prefix = NULL) { * directory as config directories. N to start with empty * $config_directories. */ -function _drupal_test_overrides($test_prefix, $config) { +function _drupal_load_test_overrides($test_prefix, $config) { global $conf, $config_directories; $path_prefix = 'simpletest/' . substr($test_prefix, 10); if ($config === 'Y') { @@ -2639,25 +2646,23 @@ function _drupal_test_overrides($test_prefix, $config) { else { $config_directories = array(); } - $dir = conf_path() . '/files/' . $path_prefix; - $filename = $dir . '/override.php'; + $filename = conf_path() . '/files/' . $path_prefix . '/settings.php'; if (file_exists($filename)) { $settings = settings()->getAll(); $conf_path = &drupal_static('conf_path'); - // This can override $conf, $conf_path and $settings. + // This can override $conf, $conf_path, $settings and + // $config_directories include $filename; + // Keep the conf_path alive across drupal_static_reset() calls. + $settings['simpletest_conf_path'] = $conf_path; new Settings($settings); } - $filename = $dir . '/settings.php'; - if (file_exists($filename)) { - include $filename; - } } /** * Generates a user agent string with a HMAC and timestamp for simpletest. */ -function drupal_generate_test_ua($prefix, $config = 'Y') { +function drupal_generate_test_ua($prefix, $config = TRUE) { global $drupal_hash_salt; static $key; @@ -2670,7 +2675,7 @@ function drupal_generate_test_ua($prefix, $config = 'Y') { // Generate a moderately secure HMAC based on the database credentials. $salt = uniqid('', TRUE); $check_string = $prefix . ';' . time() . ';' . $salt; - return $check_string . ';' . drupal_hmac_base64($check_string, $key) . $config; + return $check_string . ';' . drupal_hmac_base64($check_string, $key) . ($config ? 'Y' : 'N'); } /** diff --git a/core/includes/update.inc b/core/includes/update.inc index c0d0eee..6aea70f 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -107,6 +107,7 @@ function update_prepare_d8_bootstrap() { // Check whether settings.php needs to be rewritten. $settings_exist = !empty($GLOBALS['config_directories']); + if (!$settings_exist || !is_dir(config_get_config_directory('active')) || !is_dir(config_get_config_directory('staging'))) { drupal_install_config_directories(); } diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 99dc276..119c148 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -163,7 +163,7 @@ * Set to N if you want the child Drupal to not use the pregenerated * config directory path. */ - protected $pregeneratedConfigDirectories = 'Y'; + protected $pregeneratedConfigDirectories = TRUE; /** * Constructor for Drupal\simpletest\WebTestBase. diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalAnonymousUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalAnonymousUpgradePathTest.php index b25e848..6299c57 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalAnonymousUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalAnonymousUpgradePathTest.php @@ -6,28 +6,37 @@ namespace Drupal\system\Tests\Upgrade; - +/** + * Tests the database upgrade path without logging into Drupal 7 first. + */ class BareMinimalAnonymousUpgradePathTest extends BareMinimalUpgradePathTest { public static function getInfo() { return array( - 'name' => 'Basic minimal profile upgrade, free access', - 'description' => 'Basic upgrade path tests for a minimal profile install with a bare database and update_free_access set to TRUE.', + 'name' => 'Basic minimal profile upgrade, free access', + 'description' => 'Basic upgrade path tests for a minimal profile install with a bare database and update_free_access set to TRUE.', 'group' => 'Upgrade path', ); } + /** + * Overrides \Drupal\system\Tests\Upgrade\UpgradePathTestBase::prepareD8Session(). + */ protected function prepareD8Session() { $new_settings['settings']['update_free_access'] = (object) array( 'value' => TRUE, 'required' => TRUE, ); include_once DRUPAL_ROOT . '/core/includes/install.inc'; - $filename = $this->public_files_directory . '/override.php'; + $filename = $this->public_files_directory . '/settings.php'; file_put_contents($filename, " 'Basic minimal profile upgrade, no config', @@ -18,32 +18,35 @@ public static function getInfo() { ); } + /** + * Overrides \Drupal\system\Tests\Upgrade\UpgradePathTestBase::prepareConfigDirectories(). + */ protected function prepareConfigDirectories() { $new_settings['conf_path'] = (object) array( 'value' => $this->public_files_directory, 'required' => TRUE, ); include_once DRUPAL_ROOT . '/core/includes/install.inc'; - $filename = $this->public_files_directory . '/override.php'; + $filename = $this->public_files_directory . '/settings.php'; file_put_contents($filename, "public_files_directory . '/settings.php', "pregeneratedConfigDirectories = 'N'; - $this->configDirectoriesSet = TRUE; + $this->pregeneratedConfigDirectories = FALSE; } + /** + * Overrides \Drupal\system\Tests\Upgrade\UpgradePathTestBase::refreshVariables(). + */ protected function refreshVariables() { // Refresh the variables only if the site was already upgraded. - if ($this->upgradedSite && $this->configDirectoriesSet) { - $this->configDirectoriesSet = FALSE; + if ($this->upgradedSite) { + // update.php puts the new, randomized config directries in this file. include $this->public_files_directory . '/settings.php'; $GLOBALS['config_directories'] = array(); - include_once DRUPAL_ROOT . '/core/includes/install.inc'; foreach ($config_directories as $type => $data) { $GLOBALS['config_directories'][$type]['path'] = 'simpletest/' . substr($this->databasePrefix, 10) . '/files/' . $data['path']; } + parent::refreshVariables(); } - parent::refreshVariables(); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalUpgradePathTest.php index 7f1abdd..1156616 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalUpgradePathTest.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\system\Tests\Upgrade\BareMinimalUpgradePathTest. + * Contains \Drupal\system\Tests\Upgrade\BareMinimalUpgradePathTest. */ namespace Drupal\system\Tests\Upgrade; @@ -43,7 +43,7 @@ public function testBasicMinimalUpgrade() { $this->assertResponse(200); // Verify that we are still logged in. - $this->assertStillLoggedIn(); + $this->assertSessionKept(); $this->drupalLogin((object) array( 'uid' => 1, 'name' => 'admin', @@ -91,14 +91,13 @@ public function testBasicMinimalUpgrade() { } /** - * Assert that we are still logged in. + * Assert that the session was kept during update. Also, log out. */ - protected function assertStillLoggedin() { + protected function assertSessionKept() { $this->drupalGet('user'); $this->clickLink(t('Edit')); $this->assertEqual($this->getUrl(), url('user/1/edit', array('absolute' => TRUE)), 'We are still logged in as admin at the end of the upgrade.'); - - // Logout and verify that we can login back in with our initial password. $this->drupalLogout(); } + }