Skip to content

Commit

Permalink
Merge pull request #21403 from GValFr35/fix-session-reference-5.40
Browse files Browse the repository at this point in the history
(dev/drupal#163) Session erroneously getting set to NULL on change
  • Loading branch information
demeritcowboy authored Sep 30, 2021
2 parents 8df2a28 + 1fa3e6a commit b2fb9ff
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions CRM/Core/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@ class CRM_Core_Session {
*/
protected $_session = NULL;

/**
* Current php Session ID : needed to detect if the session is changed
*
* @var string
*/
protected $sessionID;

/**
* We only need one instance of this object. So we use the singleton
* pattern and cache the instance in this variable
Expand Down Expand Up @@ -128,10 +121,9 @@ public function isEmpty() {
* Is this a read operation, in this case, the session will not be touched.
*/
public function initialize($isRead = FALSE) {
// remove $_SESSION reference if session is changed
if (($sid = session_id()) !== $this->sessionID) {
$this->_session = NULL;
$this->sessionID = $sid;
// reset $this->_session in case if it is no longer a reference to $_SESSION;
if (isset($_SESSION) && isset($this->_session) && $_SESSION !== $this->_session) {
unset($this->_session);
}
// lets initialize the _session variable just before we need it
// hopefully any bootstrapping code will actually load the session from the CMS
Expand Down Expand Up @@ -171,9 +163,9 @@ public function reset($all = 1) {
unset($this->_session[$this->_key]);
}
else {
$this->_session = [];
$this->_session[$this->_key] = [];
unset($this->_session);
}

}

/**
Expand Down

0 comments on commit b2fb9ff

Please sign in to comment.