Skip to content

Commit

Permalink
Merge pull request #3 from tractorcow/pulls/close
Browse files Browse the repository at this point in the history
BUG Fix session_write_close being called when module is disabled.
  • Loading branch information
Damian Mooyman committed Aug 20, 2014
2 parents 6d89c07 + ee85ec5 commit 3a06065
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion code/HybridSessionStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
*/
Expand Down Expand Up @@ -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;
}
}

Expand All @@ -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();
}
}
}

0 comments on commit 3a06065

Please sign in to comment.