if (empty($this->_tasklist)) {
$this->_createTaskList();
}
+
+ register_shutdown_function(array($this, 'shutdown'));
}
/**
- * Destructor.
+ * Tasks to run on session shutdown.
*/
- public function __destruct()
+ public function shutdown()
{
if (isset($this->_tasklist)) {
$_SESSION['horde_logintasks'][$this->_app] = serialize($this->_tasklist);
protected function __construct($params = array())
{
$this->_params = $params;
+ register_shutdown_function(array($this, 'shutdown'));
}
/**
- * Destructor.
+ * Shutdown function.
*
* Used to determine if we need to write the session to avoid a session
* timeout, even though the session is unchanged.
* server via a periodic mechanism (think folder refreshing in IMP) that
* we will catch this refresh.
*/
- public function __destruct()
+ public function shutdown()
{
$curr_time = time();
if (empty($this->_params['track_lifetime'])) {
$this->_params['track_lifetime'] = ini_get('session.gc_maxlifetime');
}
- }
- /**
- * Destructor.
- */
- public function __destruct()
- {
if (!empty($this->_params['track']) && (rand(0, 999) == 0)) {
- $this->_trackGC();
+ register_shutdown_function(array($this, 'trackGC'));
}
-
- parent::__destruct();
}
/**
throw $e;
}
- $this->_trackGC();
+ $this->trackGC();
$ids = $this->_memcache->get($this->_trackID);
return ($ids === false) ? array() : array_keys($ids);
/**
* Do garbage collection for session tracking information.
*/
- protected function _trackGC()
+ public function trackGC()
{
$this->_memcache->lock($this->_trackID);
$ids = $this->_memcache->get($this->_trackID);
if (isset($params['size']) && is_int($params['size'])) {
$this->_size = $params['size'];
}
+
+ register_shutdown_function(array($this, 'shutdown'));
}
/**
- * Destructor.
+ * Tasks to run on shutdown.
*/
- public function __destruct()
+ public function shutdown()
{
/* Prune old entries. */
if (isset($_SESSION[$this->_name]['__prune']) &&