8000 Use destructor to close session (partially reverted #348) (#412) · snc/SncRedisBundle@b133296 · GitHub
[go: up one dir, main page]

Skip to content

Commit b133296

Browse files
supersmile2009curry684
authored andcommitted
Use destructor to close session (partially reverted #348) (#412)
* Use destructor to shutdown session (partially reverted #348) * Register shutdown function only if session locking is enabled (cherry picked from commit ae3a607)
1 parent afaa0c4 commit b133296

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Session/Storage/Handler/RedisSessionHandler.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ public function __construct($redis, array $options = array(), $prefix = 'session
101101
$this->lockMaxWait = self::DEFAULT_MAX_EXECUTION_TIME;
102102
}
103103

104-
register_shutdown_function(array($this, 'shutdown'));
104+
if (true === $locking) {
105+
register_shutdown_function(array($this, 'shutdown'));
106+
}
105107
}
106108

107109
/**
@@ -277,7 +279,16 @@ protected function getRedisKey($key)
277279
/**
278280
* Shutdown handler, replacement for class destructor as it might not be called.
279281
*/
280-
public function shutdown() {
282+
public function shutdown()
283+
{
281284
$this->close();
282285
}
286+
287+
/**
288+
* Destructor.
289+
*/
290+
public function __destruct()
291+
{
292+
$this->shutdown();
293+
}
283294
}

0 commit comments

Comments
 (0)
0