Skip to content

Commit 0ad5dd5

Browse files
bug #34827 [HttpFoundation] get currently session.gc_maxlifetime if ttl doesnt exists (rafaeltovar)
This PR was submitted for the master branch but it was squashed and merged into the 4.4 branch instead. Discussion ---------- [HttpFoundation] get currently session.gc_maxlifetime if ttl doesnt exists | Q | A | ------------- | --- | Branch? | master / 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #34659 | License | MIT If option `ttl` was not defined in RedisSessionHandler, this got the default `session.gc_maxlifetime`. With this fixed, RedisSessionHandler get the currently `session.gc_maxlifetime`. Commits ------- b6253e2 [HttpFoundation] get currently session.gc_maxlifetime if ttl doesnt exists
2 parents bfe697b + b6253e2 commit 0ad5dd5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function __construct($redis, array $options = [])
6363

6464
$this->redis = $redis;
6565
$this->prefix = $options['prefix'] ?? 'sf_s';
66-
$this->ttl = $options['ttl'] ?? (int) ini_get('session.gc_maxlifetime');
66+
$this->ttl = $options['ttl'] ?? null;
6767
}
6868

6969
/**
@@ -79,7 +79,7 @@ protected function doRead($sessionId): string
7979
*/
8080
protected function doWrite($sessionId, $data): bool
8181
{
82-
$result = $this->redis->setEx($this->prefix.$sessionId, $this->ttl, $data);
82+
$result = $this->redis->setEx($this->prefix.$sessionId, (int) ($this->ttl ?? ini_get('session.gc_maxlifetime')), $data);
8383

8484
return $result && !$result instanceof ErrorInterface;
8585
}
@@ -115,6 +115,6 @@ public function gc($maxlifetime): bool
115115
*/
116116
public function updateTimestamp($sessionId, $data)
117117
{
118-
return (bool) $this->redis->expire($this->prefix.$sessionId, $this->ttl);
118+
return (bool) $this->redis->expire($this->prefix.$sessionId, (int) ($this->ttl ?? ini_get('session.gc_maxlifetime')));
119119
}
120120
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy