-
Notifications
You must be signed in to change notification settings - Fork 326
Closed
Labels
dxDeveloper eXperienceDeveloper eXperienceenhancementImproves existing functionalityImproves existing functionality
Milestone
Description
The RedisSessionHandler::$lockKey
gets prefixed with just the prefix without the colon ($this->prefix.$lockKey
), but every other session related sessions get prefixed with $this->prefix.':'.$sessionId
). Lock key should also have a colon after the prefix ($this->prefix.':'.$this->lockKey
). I've generated a patch to fix this. I'd give you a PR but I'm not sure where to point the PR to. You can apply this by saving it as diff.patch
and running: patch -p0 < diff.patch
.
This was asked about in #181 as well. There's already a PR to master #158 but this is for 1.1.
Below is the patch:
diff --git Session/Storage/Handler/RedisSessionHandler.php Session/Storage/Handler/RedisSessionHandler.php
index b6ad274..092ebfd 100644
--- Session/Storage/Handler/RedisSessionHandler.php
+++ Session/Storage/Handler/RedisSessionHandler.php
@@ -108,10 +108,10 @@ class RedisSessionHandler implements \SessionHandlerInterface
$this->lockKey = $sessionId.'.lock';
for ($i=0;$i<$attempts;$i++) {
- $success = $this->redis->setnx($this->prefix.$this->lockKey, '1');
+ $success = $this->redis->setnx($this->getLockKey(), '1');
if ($success) {
$this->locked = true;
- $this->redis->expire($this->prefix.$this->lockKey, $this->lockMaxWait + 1);
+ $this->redis->expire($this->getLockKey(), $this->lockMaxWait + 1);
return true;
}
usleep($this->spinLockWait);
@@ -122,7 +122,7 @@ class RedisSessionHandler implements \SessionHandlerInterface
private function unlockSession()
{
- $this->redis->del($this->prefix.$this->lockKey);
+ $this->redis->del($this->getLockKey());
$this->locked = false;
}
@@ -213,6 +213,11 @@ class RedisSessionHandler implements \SessionHandlerInterface
return $this->prefix . ':' . $sessionId;
}
+ public function getLockKey()
+ {
+ return $this->getRedisKey($this->lockKey);
+ }
+
/**
* Destructor
*/
Metadata
Metadata
Assignees
Labels
dxDeveloper eXperienceDeveloper eXperienceenhancementImproves existing functionalityImproves existing functionality