From 671f655b395151fb9899ef9d76a02cecfcd0498d Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 9 Jan 2020 12:07:25 +1300 Subject: [PATCH] [REF] move sessionStart functionality to System subclass Preparatory to https://github.com/civicrm/civicrm-core/pull/15131/files --- CRM/Core/Session.php | 12 +----------- CRM/Utils/System/Base.php | 7 +++++++ CRM/Utils/System/DrupalBase.php | 18 ++++++++++++++++-- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/CRM/Core/Session.php b/CRM/Core/Session.php index 75936e7f94..8cbcfdfead 100644 --- a/CRM/Core/Session.php +++ b/CRM/Core/Session.php @@ -108,17 +108,7 @@ class CRM_Core_Session { if ($isRead) { return; } - // FIXME: This belongs in CRM_Utils_System_* - if (CRM_Core_Config::singleton()->userSystem->is_drupal && function_exists('drupal_session_start')) { - // https://issues.civicrm.org/jira/browse/CRM-14356 - if (!(isset($GLOBALS['lazy_session']) && $GLOBALS['lazy_session'] == TRUE)) { - drupal_session_start(); - } - $_SESSION = []; - } - else { - session_start(); - } + CRM_Core_Config::singleton()->userSystem->sessionStart(); } $this->_session =& $_SESSION; } diff --git a/CRM/Utils/System/Base.php b/CRM/Utils/System/Base.php index 8f16278794..20bf040b94 100644 --- a/CRM/Utils/System/Base.php +++ b/CRM/Utils/System/Base.php @@ -974,4 +974,11 @@ abstract class CRM_Utils_System_Base { CRM_Utils_System::civiExit(); } + /** + * Start a new session. + */ + public function sessionStart() { + session_start(); + } + } diff --git a/CRM/Utils/System/DrupalBase.php b/CRM/Utils/System/DrupalBase.php index 5521bd4efd..27e11078ef 100644 --- a/CRM/Utils/System/DrupalBase.php +++ b/CRM/Utils/System/DrupalBase.php @@ -13,8 +13,6 @@ * * @package CRM * @copyright CiviCRM LLC https://civicrm.org/licensing - * $Id$ - * */ /** @@ -667,4 +665,20 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base { return FALSE; } + /** + * Start a new session. + */ + public function sessionStart() { + if (function_exists('drupal_session_start')) { + // https://issues.civicrm.org/jira/browse/CRM-14356 + if (!(isset($GLOBALS['lazy_session']) && $GLOBALS['lazy_session'] == TRUE)) { + drupal_session_start(); + } + $_SESSION = []; + } + else { + session_start(); + } + } + } -- 2.25.1