diff --git a/Session/Storage/Handler/RedisSessionHandler.php b/Session/Storage/Handler/RedisSessionHandler.php index e3616b5b..c043704c 100644 --- a/Session/Storage/Handler/RedisSessionHandler.php +++ b/Session/Storage/Handler/RedisSessionHandler.php @@ -99,7 +99,9 @@ public function __construct($redis, array $options = array(), $prefix = 'session $this->lockMaxWait = self::DEFAULT_MAX_EXECUTION_TIME; } - register_shutdown_function(array($this, 'shutdown')); + if (true === $locking) { + register_shutdown_function(array($this, 'shutdown')); + } } /** @@ -270,7 +272,16 @@ protected function getRedisKey($key) /** * Shutdown handler, replacement for class destructor as it might not be called. */ - public function shutdown() { + public function shutdown() + { $this->close(); } + + /** + * Destructor. + */ + public function __destruct() + { + $this->shutdown(); + } }