[REF] move sessionStart functionality to System subclass
authoreileen <emcnaughton@wikimedia.org>
Wed, 8 Jan 2020 23:07:25 +0000 (12:07 +1300)
committereileen <emcnaughton@wikimedia.org>
Wed, 8 Jan 2020 23:07:25 +0000 (12:07 +1300)
Preparatory to https://github.com/civicrm/civicrm-core/pull/15131/files

CRM/Core/Session.php
CRM/Utils/System/Base.php
CRM/Utils/System/DrupalBase.php

index 75936e7f94127d7d6e3e73f743f7dbc86d72431c..8cbcfdfeada0d42acd5969301bd5eac19e54f1bf 100644 (file)
@@ -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;
     }
index 8f16278794ae39a4f629981a23bd4c55f7c84447..20bf040b94da471fc3d88ba71dedb79f79378ae4 100644 (file)
@@ -974,4 +974,11 @@ abstract class CRM_Utils_System_Base {
     CRM_Utils_System::civiExit();
   }
 
+  /**
+   * Start a new session.
+   */
+  public function sessionStart() {
+    session_start();
+  }
+
 }
index 5521bd4efd22f16b7fba5aeb8386de0ae2d1e273..27e11078efdb9a77433ba58e104b5e1c92bbed20 100644 (file)
@@ -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();
+    }
+  }
+
 }