#945112 by carlos8f, dalin, David_Rothstein: Fixed Unable to stay logged in during upgrade from D6 -> D7
parent
7eb6f7cb44
commit
104d6197a8
|
@ -156,6 +156,15 @@ function update_prepare_d7_bootstrap() {
|
|||
),
|
||||
);
|
||||
update_extra_requirements($requirements);
|
||||
|
||||
// Allow a D6 session to work, since the upgrade has not been performed yet.
|
||||
$d6_session_name = update_get_d6_session_name();
|
||||
if (!empty($_COOKIE[$d6_session_name])) {
|
||||
// Set the current sid to the one found in the D6 cookie.
|
||||
$sid = $_COOKIE[$d6_session_name];
|
||||
$_COOKIE[session_name()] = $sid;
|
||||
session_id($sid);
|
||||
}
|
||||
}
|
||||
|
||||
// Create the registry tables.
|
||||
|
@ -828,6 +837,37 @@ function update_parse_db_url($db_url, $db_prefix) {
|
|||
return $databases;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a session name compatible with a D6 environment.
|
||||
*
|
||||
* @return
|
||||
* D6-compatible session name string.
|
||||
*
|
||||
* @see drupal_settings_initialize()
|
||||
*/
|
||||
function update_get_d6_session_name() {
|
||||
global $base_url, $cookie_domain;
|
||||
$cookie_secure = ini_get('session.cookie_secure');
|
||||
|
||||
// If a custom cookie domain is set in settings.php, that variable forms
|
||||
// the basis of the session name. Re-compute the D7 hashing method to find
|
||||
// out if $cookie_domain was used as the session name.
|
||||
if (($cookie_secure ? 'SSESS' : 'SESS') . substr(hash('sha256', $cookie_domain), 0, 32) == session_name()) {
|
||||
$session_name = $cookie_domain;
|
||||
}
|
||||
else {
|
||||
// Otherwise use $base_url as session name, without the protocol
|
||||
// to use the same session identifiers across http and https.
|
||||
list( , $session_name) = explode('://', $base_url, 2);
|
||||
}
|
||||
|
||||
if ($cookie_secure) {
|
||||
$session_name .= 'SSL';
|
||||
}
|
||||
|
||||
return 'SESS' . md5($session_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform one update and store the results for display on finished page.
|
||||
*
|
||||
|
|
|
@ -34,6 +34,9 @@ abstract class UpgradePathTestCase extends DrupalWebTestCase {
|
|||
protected function setUp() {
|
||||
global $user, $language, $conf;
|
||||
|
||||
// Load the Update API.
|
||||
require_once DRUPAL_ROOT . '/includes/update.inc';
|
||||
|
||||
// Reset flags.
|
||||
$this->upgradedSite = FALSE;
|
||||
$this->upgradeErrors = array();
|
||||
|
@ -106,10 +109,11 @@ abstract class UpgradePathTestCase extends DrupalWebTestCase {
|
|||
drupal_save_session(FALSE);
|
||||
$user = db_query('SELECT * FROM {users} WHERE uid = :uid', array(':uid' => 1))->fetchObject();
|
||||
|
||||
// Generate and set a session cookie.
|
||||
// Generate and set a D6-compatible session cookie.
|
||||
$this->curlInitialize();
|
||||
$sid = drupal_hash_base64(uniqid(mt_rand(), TRUE) . drupal_random_bytes(55));
|
||||
curl_setopt($this->curlHandle, CURLOPT_COOKIE, rawurlencode($this->session_name) . '=' . rawurlencode($sid));
|
||||
$session_name = update_get_d6_session_name();
|
||||
curl_setopt($this->curlHandle, CURLOPT_COOKIE, rawurlencode($session_name) . '=' . rawurlencode($sid));
|
||||
|
||||
// Force our way into the session of the child site.
|
||||
drupal_save_session(TRUE);
|
||||
|
|
Loading…
Reference in New Issue