From f2e906d7aa52512762a30f9cae4b5bdd3ea8f6b7 Mon Sep 17 00:00:00 2001 From: Jitendra Purohit Date: Tue, 13 Jun 2017 16:41:00 +0530 Subject: [PATCH] CRM-20728: Store session in drupal before exiting --- CRM/Utils/System.php | 8 ++++++++ CRM/Utils/System/Drupal.php | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/CRM/Utils/System.php b/CRM/Utils/System.php index bee39e8e0b..5f1829131a 100644 --- a/CRM/Utils/System.php +++ b/CRM/Utils/System.php @@ -1404,6 +1404,14 @@ class CRM_Utils_System { // move things to CiviCRM cache as needed CRM_Core_Session::storeSessionObjects(); + if (Civi\Core\Container::isContainerBooted()) { + Civi::dispatcher()->dispatch('civi.core.exit'); + } + + $userSystem = CRM_Core_Config::singleton()->userSystem; + if (is_callable(array($userSystem, 'onCiviExit'))) { + $userSystem->onCiviExit(); + } exit($status); } diff --git a/CRM/Utils/System/Drupal.php b/CRM/Utils/System/Drupal.php index 1c9d8b2880..71f8f997ff 100644 --- a/CRM/Utils/System/Drupal.php +++ b/CRM/Utils/System/Drupal.php @@ -842,4 +842,15 @@ AND u.status = 1 ); } + /** + * Commit the session before exiting. + * Similar to drupal_exit(). + */ + public function onCiviExit() { + if (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update') { + module_invoke_all('exit'); + } + drupal_session_commit(); + } + } -- 2.25.1