mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-19 05:07:50 +09:00
Update dependencies
This commit is contained in:
@@ -21,17 +21,17 @@ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
|
||||
*/
|
||||
class MemcachedSessionHandler extends AbstractSessionHandler
|
||||
{
|
||||
private $memcached;
|
||||
private \Memcached $memcached;
|
||||
|
||||
/**
|
||||
* @var int Time to live in seconds
|
||||
* Time to live in seconds.
|
||||
*/
|
||||
private $ttl;
|
||||
private int|\Closure|null $ttl;
|
||||
|
||||
/**
|
||||
* @var string Key prefix for shared environments
|
||||
* Key prefix for shared environments.
|
||||
*/
|
||||
private $prefix;
|
||||
private string $prefix;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -54,57 +54,49 @@ class MemcachedSessionHandler extends AbstractSessionHandler
|
||||
$this->prefix = $options['prefix'] ?? 'sf2s';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function close()
|
||||
public function close(): bool
|
||||
{
|
||||
return $this->memcached->quit();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doRead(string $sessionId)
|
||||
protected function doRead(#[\SensitiveParameter] string $sessionId): string
|
||||
{
|
||||
return $this->memcached->get($this->prefix.$sessionId) ?: '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function updateTimestamp($sessionId, $data)
|
||||
public function updateTimestamp(#[\SensitiveParameter] string $sessionId, string $data): bool
|
||||
{
|
||||
$this->memcached->touch($this->prefix.$sessionId, time() + (int) ($this->ttl ?? \ini_get('session.gc_maxlifetime')));
|
||||
$this->memcached->touch($this->prefix.$sessionId, $this->getCompatibleTtl());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doWrite(string $sessionId, string $data)
|
||||
protected function doWrite(#[\SensitiveParameter] string $sessionId, string $data): bool
|
||||
{
|
||||
return $this->memcached->set($this->prefix.$sessionId, $data, time() + (int) ($this->ttl ?? \ini_get('session.gc_maxlifetime')));
|
||||
return $this->memcached->set($this->prefix.$sessionId, $data, $this->getCompatibleTtl());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDestroy(string $sessionId)
|
||||
private function getCompatibleTtl(): int
|
||||
{
|
||||
$ttl = ($this->ttl instanceof \Closure ? ($this->ttl)() : $this->ttl) ?? \ini_get('session.gc_maxlifetime');
|
||||
|
||||
// If the relative TTL that is used exceeds 30 days, memcached will treat the value as Unix time.
|
||||
// We have to convert it to an absolute Unix time at this point, to make sure the TTL is correct.
|
||||
if ($ttl > 60 * 60 * 24 * 30) {
|
||||
$ttl += time();
|
||||
}
|
||||
|
||||
return $ttl;
|
||||
}
|
||||
|
||||
protected function doDestroy(#[\SensitiveParameter] string $sessionId): bool
|
||||
{
|
||||
$result = $this->memcached->delete($this->prefix.$sessionId);
|
||||
|
||||
return $result || \Memcached::RES_NOTFOUND == $this->memcached->getResultCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|false
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function gc($maxlifetime)
|
||||
public function gc(int $maxlifetime): int|false
|
||||
{
|
||||
// not required here because memcached will auto expire the records anyhow.
|
||||
return 0;
|
||||
@@ -112,10 +104,8 @@ class MemcachedSessionHandler extends AbstractSessionHandler
|
||||
|
||||
/**
|
||||
* Return a Memcached instance.
|
||||
*
|
||||
* @return \Memcached
|
||||
*/
|
||||
protected function getMemcached()
|
||||
protected function getMemcached(): \Memcached
|
||||
{
|
||||
return $this->memcached;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user