diff -u b/core/includes/bootstrap.inc b/core/includes/bootstrap.inc --- b/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -2456,16 +2456,21 @@ /** * Returns the test prefix if this is an internal request from SimpleTest. * + * @param string $new_prefix + * Internal use only. A new prefix to be stored. + * * @return * Either the simpletest prefix (the string "simpletest" followed by any * number of digits) or FALSE if the user agent does not contain a valid * HMAC and timestamp. */ -function drupal_valid_test_ua() { +function drupal_valid_test_ua($new_prefix = NULL) { global $drupal_hash_salt; - // No reason to reset this. static $test_prefix; + if (isset($new_prefix)) { + $test_prefix = $new_prefix; + } if (isset($test_prefix)) { return $test_prefix; } diff -u b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php --- b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -122,11 +122,11 @@ protected $verboseDirectory; /** - * The original value of $_SERVER['HTTP_USER_AGENT'] + * The original database prefix when running inside Simpletest. * * @var string */ - protected $originalUserAgent; + protected $originalPrefix; /** * Constructor for Test. @@ -748,8 +748,8 @@ $GLOBALS['config_directories'][$type]['path'] = 'simpletest/' . substr($this->databasePrefix, 10) . '/config_' . $type; } if (drupal_valid_test_ua()) { - $this->originalUserAgent = $_SERVER['HTTP_USER_AGENT']; - $_SERVER['HTTP_USER_AGENT'] = drupal_generate_test_ua($this->databasePrefix); + $this->originalPrefix = drupal_valid_test_ua(); + drupal_valid_test_ua($this->databasePrefix); } // Reset and create a new service container. @@ -838,7 +838,9 @@ drupal_container($this->originalContainer); $language_interface = $this->originalLanguage; $GLOBALS['config_directories'] = $this->originalConfigDirectories; - $_SERVER['HTTP_USER_AGENT'] = $this->originalUserAgent; + if (isset($this->originalPrefix)) { + drupal_valid_test_ua($this->originalPrefix); + } // Restore original shutdown callbacks. $callbacks = &drupal_register_shutdown_function();