diff -u b/core/includes/install.core.inc b/core/includes/install.core.inc --- b/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -460,7 +460,7 @@ } elseif ($task['type'] == 'batch') { - if (!$install_state['interactive']) { + if (0 && !$install_state['interactive']) { $batch = $function($install_state); if (!empty($batch['operations'])) { // Build a dummy 'context' array to avoid exceptions. 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 @@ -636,9 +636,11 @@ // Save further contextual information. $this->originalFileDirectory = variable_get('file_public_path', conf_path() . '/files'); $this->originalProfile = drupal_get_profile(); - $this->originalUser = $user; + $this->originalUser = clone $user; +// $this->originalSessionID = session_id(); // $this->originalSession = isset($_SESSION) ? $_SESSION : NULL; - $this->originalGlobals = $GLOBALS; +// $this->originalCookies = $_COOKIE; +// $this->originalGlobals = $GLOBALS; // Save and clean the shutdown callbacks array because it is static cached // and will be changed by the test run. Otherwise it will contain callbacks @@ -733,8 +735,10 @@ // Restore original user session. $user = $this->originalUser; +// session_id($this->originalSessionID); // $_SESSION = $this->originalSession; - $GLOBALS = $this->originalGlobals; +// $_COOKIE = $this->originalCookies; +// $GLOBALS = $this->originalGlobals; drupal_save_session(TRUE); } diff -u b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php --- b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -580,16 +580,18 @@ protected function setUp() { global $user, $conf; $language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE); - //Get old batch id and token - $batch = batch_get(); - if(!empty($batch['id'])) { - $this->batch_id = $batch['id']; - $this->old_token = drupal_get_token($this->batch_id); - } - else { - $this->batch_id = NULL; - $this->old_token = NULL; - } + + // When running tests through the Simpletest UI (vs. on the command line), + // Simpletest's batch conflicts with the installer's batch. Batch API does + // not support the concept of nested batches (in which the nested is not + // progressive), so we need to temporarily pretend there was no batch. + // Backup the currently running Simpletest batch. + $this->originalBatch = batch_get(); + +// if (!empty($this->originalBatch['id'])) { +// $this->originalToken = drupal_get_token($this->originalBatch['id']); +// } + // Create the database prefix for this test. $this->prepareDatabasePrefix(); @@ -654,19 +656,12 @@ ), ), ); - // When running tests through the Simpletest UI (vs. on the command line), - // Simpletest's batch conflicts with the installer's batch. Batch API does - // not support the concept of nested batches (in which the nested is not - // progressive), so we need to temporarily pretend there was no batch. - // Backup the currently running Simpletest batch. -// $parent_batch = batch_get(); - // $parent_session = $_SESSION; // $parent_get = $_GET; // Reset it and invoke the non-interactive installer. -// $batch = &batch_get(); -// $batch = array(); + $batch = &batch_get(); + $batch = array(); // @todo The above has been replaced with changing install_run_task() in // install.core.inc to not invoke the Batch API at all for install tasks @@ -677,20 +672,26 @@ // the current user. drupal_get_token() returns a different value after // test execution, so the batch finished page does not load. // $session_id = session_id(); - $originalSession = isset($_SESSION) ? $_SESSION : NULL; - $originalGlobals = $GLOBALS; - $request = request(); + +// $originalSession = isset($_SESSION) ? $_SESSION : NULL; +// $originalGlobals = $GLOBALS; +// $request = request(); + $originalConf = $conf; + $user = drupal_anonymous_user(); + drupal_save_session(FALSE); install_drupal($settings); // session_id($session_id); - $_SESSION = $originalSession; - $GLOBALS = $originalGlobals; - request($request); + +// $_SESSION = $originalSession; +// $GLOBALS = $originalGlobals; +// request($request); + $conf = $originalConf; // Restore the original Simpletest batch. -// $batch = &batch_get(); -// $batch = $parent_batch; + $batch = &batch_get(); + $batch = $this->originalBatch; // $_SESSION = $parent_session; // $_GET = $parent_get; @@ -728,7 +729,6 @@ // Ensure that the session is not written to the new environment and replace // the global $user session with uid 1 from the new test site. - drupal_save_session(FALSE); // Login as uid 1. $user = user_load(1); @@ -815,13 +815,13 @@ // Close the CURL handler. $this->curlClose(); - if(!empty($this->batch_id)) { - //Regenerate batch token after install_drupal created a new session_id. + // Regenerate batch token after install_drupal() created a new session_id. + if (0 && !empty($this->originalBatch)) { db_update('batch') ->fields(array( - 'token' => drupal_get_token($this->batch_id), + 'token' => drupal_get_token($this->originalBatch['id']), )) - ->condition('token', $this->old_token) + ->condition('token', $this->originalToken) ->execute(); } } only in patch2: unchanged: --- a/core/includes/session.inc +++ b/core/includes/session.inc @@ -348,6 +348,12 @@ function drupal_session_started($set = NULL) { */ function drupal_session_regenerate() { global $user, $is_https; + + // Nothing to do if we are not allowed to save the session. + if (!drupal_save_session()) { + return; + } + if ($is_https && variable_get('https', FALSE)) { $insecure_session_name = substr(session_name(), 1); if (!isset($GLOBALS['lazy_session']) && isset($_COOKIE[$insecure_session_name])) { @@ -417,6 +423,11 @@ function drupal_session_regenerate() { function _drupal_session_destroy($sid) { global $user, $is_https; + // Nothing to do if we are not allowed to save the session. + if (!drupal_save_session()) { + return; + } + // Delete session data. db_delete('sessions') ->condition($is_https ? 'ssid' : 'sid', $sid) @@ -464,6 +475,11 @@ function _drupal_session_delete_cookie($name, $secure = NULL) { * User ID. */ function drupal_session_destroy_uid($uid) { + // Nothing to do if we are not allowed to save the session. + if (!drupal_save_session()) { + return; + } + db_delete('sessions') ->condition('uid', $uid) ->execute(); @@ -506,7 +522,7 @@ function _drupal_session_garbage_collection($lifetime) { * FALSE if writing session data has been disabled. Otherwise, TRUE. */ function drupal_save_session($status = NULL) { - $save_session = &drupal_static(__FUNCTION__, TRUE); + static $save_session = TRUE; if (isset($status)) { $save_session = $status; }