From ee85ec515915d8e41bd3ae8b42146962a259222a Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Wed, 20 Aug 2014 17:34:35 +1200 Subject: [PATCH] BUG Fix session_write_close being called when module is disabled. --- code/HybridSessionStore.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/code/HybridSessionStore.php b/code/HybridSessionStore.php index 37f9552..067555a 100644 --- a/code/HybridSessionStore.php +++ b/code/HybridSessionStore.php @@ -444,6 +444,13 @@ class HybridSessionStore extends HybridSessionStore_Base { */ protected $handlers = array(); + /** + * True if this session store has been initialised + * + * @var bool + */ + protected static $enabled = false; + /** * @param array[HybridSessionStore_Base] */ @@ -524,6 +531,11 @@ public static function init($key = null) { $instance->setKey($key); } register_sessionhandler($instance); + self::$enabled = true; + } + + public static function is_enabled() { + return self::$enabled; } } @@ -533,6 +545,8 @@ public function preRequest(SS_HTTPRequest $request, Session $session, DataModel } public function postRequest(SS_HTTPRequest $request, SS_HTTPResponse $response, DataModel $model) { - session_write_close(); + if(HybridSessionStore::is_enabled()) { + session_write_close(); + } } }