Skip to content

Commit

Permalink
fix session change in drupal 9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
demeritcowboy committed Nov 13, 2021
1 parent aa959f0 commit a318248
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CRM/Core/Key.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static function sessionID() {
$session = CRM_Core_Session::singleton();
self::$_sessionID = $session->get('qfSessionID');
if (!self::$_sessionID) {
self::$_sessionID = session_id();
self::$_sessionID = CRM_Core_Config::singleton()->userSystem->getSessionId();
$session->set('qfSessionID', self::$_sessionID);
}
}
Expand Down
9 changes: 9 additions & 0 deletions CRM/Utils/System/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,15 @@ public function sessionStart() {
session_start();
}

/**
* This exists because of https://www.drupal.org/node/3006306 where
* they changed so that they don't start sessions for anonymous, but we
* want that.
*/
public function getSessionId() {
return session_id();
}

/**
* Get role names
*
Expand Down
14 changes: 14 additions & 0 deletions CRM/Utils/System/Drupal8.php
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,20 @@ public function sessionStart() {
}
}

/**
* @inheritdoc
*/
public function getSessionId() {
if (\Drupal::hasContainer()) {
$session = \Drupal::service('session');
if (!$session->has('civicrm.tempstore.sessionid')) {
$session->set('civicrm.tempstore.sessionid', \Drupal\Component\Utility\Crypt::randomBytesBase64());
}
return $session->get('civicrm.tempstore.sessionid');
}
return '';
}

/**
* Load the user object.
*
Expand Down

0 comments on commit a318248

Please sign in to comment.