upgraded dependencies
This commit is contained in:
@@ -13,6 +13,8 @@ namespace Symfony\Component\HttpFoundation\Session\Attribute;
|
||||
|
||||
/**
|
||||
* This class relates to session attribute storage.
|
||||
*
|
||||
* @implements \IteratorAggregate<string, mixed>
|
||||
*/
|
||||
class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Countable
|
||||
{
|
||||
@@ -37,7 +39,7 @@ class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Counta
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName($name)
|
||||
public function setName(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
@@ -61,7 +63,7 @@ class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Counta
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function has($name)
|
||||
public function has(string $name)
|
||||
{
|
||||
return \array_key_exists($name, $this->attributes);
|
||||
}
|
||||
@@ -69,7 +71,7 @@ class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Counta
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($name, $default = null)
|
||||
public function get(string $name, $default = null)
|
||||
{
|
||||
return \array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default;
|
||||
}
|
||||
@@ -77,7 +79,7 @@ class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Counta
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set($name, $value)
|
||||
public function set(string $name, $value)
|
||||
{
|
||||
$this->attributes[$name] = $value;
|
||||
}
|
||||
@@ -104,7 +106,7 @@ class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Counta
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function remove($name)
|
||||
public function remove(string $name)
|
||||
{
|
||||
$retval = null;
|
||||
if (\array_key_exists($name, $this->attributes)) {
|
||||
@@ -129,7 +131,7 @@ class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Counta
|
||||
/**
|
||||
* Returns an iterator for attributes.
|
||||
*
|
||||
* @return \ArrayIterator An \ArrayIterator instance
|
||||
* @return \ArrayIterator<string, mixed>
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getIterator()
|
||||
@@ -140,7 +142,7 @@ class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Counta
|
||||
/**
|
||||
* Returns the number of attributes.
|
||||
*
|
||||
* @return int The number of attributes
|
||||
* @return int
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function count()
|
||||
|
@@ -23,34 +23,30 @@ interface AttributeBagInterface extends SessionBagInterface
|
||||
/**
|
||||
* Checks if an attribute is defined.
|
||||
*
|
||||
* @param string $name The attribute name
|
||||
*
|
||||
* @return bool true if the attribute is defined, false otherwise
|
||||
* @return bool
|
||||
*/
|
||||
public function has($name);
|
||||
public function has(string $name);
|
||||
|
||||
/**
|
||||
* Returns an attribute.
|
||||
*
|
||||
* @param string $name The attribute name
|
||||
* @param mixed $default The default value if not found
|
||||
* @param mixed $default The default value if not found
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($name, $default = null);
|
||||
public function get(string $name, $default = null);
|
||||
|
||||
/**
|
||||
* Sets an attribute.
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function set($name, $value);
|
||||
public function set(string $name, $value);
|
||||
|
||||
/**
|
||||
* Returns attributes.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function all();
|
||||
|
||||
@@ -59,9 +55,7 @@ interface AttributeBagInterface extends SessionBagInterface
|
||||
/**
|
||||
* Removes an attribute.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return mixed The removed value or null when it does not exist
|
||||
*/
|
||||
public function remove($name);
|
||||
public function remove(string $name);
|
||||
}
|
||||
|
@@ -11,11 +11,15 @@
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\Session\Attribute;
|
||||
|
||||
trigger_deprecation('symfony/http-foundation', '5.3', 'The "%s" class is deprecated.', NamespacedAttributeBag::class);
|
||||
|
||||
/**
|
||||
* This class provides structured storage of session attributes using
|
||||
* a name spacing character in the key.
|
||||
*
|
||||
* @author Drak <drak@zikula.org>
|
||||
*
|
||||
* @deprecated since Symfony 5.3
|
||||
*/
|
||||
class NamespacedAttributeBag extends AttributeBag
|
||||
{
|
||||
@@ -34,7 +38,7 @@ class NamespacedAttributeBag extends AttributeBag
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function has($name)
|
||||
public function has(string $name)
|
||||
{
|
||||
// reference mismatch: if fixed, re-introduced in array_key_exists; keep as it is
|
||||
$attributes = $this->resolveAttributePath($name);
|
||||
@@ -50,7 +54,7 @@ class NamespacedAttributeBag extends AttributeBag
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($name, $default = null)
|
||||
public function get(string $name, $default = null)
|
||||
{
|
||||
// reference mismatch: if fixed, re-introduced in array_key_exists; keep as it is
|
||||
$attributes = $this->resolveAttributePath($name);
|
||||
@@ -66,7 +70,7 @@ class NamespacedAttributeBag extends AttributeBag
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set($name, $value)
|
||||
public function set(string $name, $value)
|
||||
{
|
||||
$attributes = &$this->resolveAttributePath($name, true);
|
||||
$name = $this->resolveKey($name);
|
||||
@@ -76,7 +80,7 @@ class NamespacedAttributeBag extends AttributeBag
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function remove($name)
|
||||
public function remove(string $name)
|
||||
{
|
||||
$retval = null;
|
||||
$attributes = &$this->resolveAttributePath($name);
|
||||
@@ -99,7 +103,7 @@ class NamespacedAttributeBag extends AttributeBag
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
protected function &resolveAttributePath($name, $writeContext = false)
|
||||
protected function &resolveAttributePath(string $name, bool $writeContext = false)
|
||||
{
|
||||
$array = &$this->attributes;
|
||||
$name = (str_starts_with($name, $this->namespaceCharacter)) ? substr($name, 1) : $name;
|
||||
@@ -144,11 +148,9 @@ class NamespacedAttributeBag extends AttributeBag
|
||||
*
|
||||
* This is the last part in a dot separated string.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function resolveKey($name)
|
||||
protected function resolveKey(string $name)
|
||||
{
|
||||
if (false !== $pos = strrpos($name, $this->namespaceCharacter)) {
|
||||
$name = substr($name, $pos + 1);
|
||||
|
@@ -38,7 +38,7 @@ class AutoExpireFlashBag implements FlashBagInterface
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName($name)
|
||||
public function setName(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ class AutoExpireFlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function add($type, $message)
|
||||
public function add(string $type, $message)
|
||||
{
|
||||
$this->flashes['new'][$type][] = $message;
|
||||
}
|
||||
@@ -68,7 +68,7 @@ class AutoExpireFlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function peek($type, array $default = [])
|
||||
public function peek(string $type, array $default = [])
|
||||
{
|
||||
return $this->has($type) ? $this->flashes['display'][$type] : $default;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ class AutoExpireFlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($type, array $default = [])
|
||||
public function get(string $type, array $default = [])
|
||||
{
|
||||
$return = $default;
|
||||
|
||||
@@ -122,7 +122,7 @@ class AutoExpireFlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set($type, $messages)
|
||||
public function set(string $type, $messages)
|
||||
{
|
||||
$this->flashes['new'][$type] = (array) $messages;
|
||||
}
|
||||
@@ -130,7 +130,7 @@ class AutoExpireFlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function has($type)
|
||||
public function has(string $type)
|
||||
{
|
||||
return \array_key_exists($type, $this->flashes['display']) && $this->flashes['display'][$type];
|
||||
}
|
||||
|
@@ -38,7 +38,7 @@ class FlashBag implements FlashBagInterface
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName($name)
|
||||
public function setName(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ class FlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function add($type, $message)
|
||||
public function add(string $type, $message)
|
||||
{
|
||||
$this->flashes[$type][] = $message;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ class FlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function peek($type, array $default = [])
|
||||
public function peek(string $type, array $default = [])
|
||||
{
|
||||
return $this->has($type) ? $this->flashes[$type] : $default;
|
||||
}
|
||||
@@ -78,7 +78,7 @@ class FlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($type, array $default = [])
|
||||
public function get(string $type, array $default = [])
|
||||
{
|
||||
if (!$this->has($type)) {
|
||||
return $default;
|
||||
@@ -105,7 +105,7 @@ class FlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set($type, $messages)
|
||||
public function set(string $type, $messages)
|
||||
{
|
||||
$this->flashes[$type] = (array) $messages;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ class FlashBag implements FlashBagInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function has($type)
|
||||
public function has(string $type)
|
||||
{
|
||||
return \array_key_exists($type, $this->flashes) && $this->flashes[$type];
|
||||
}
|
||||
|
@@ -23,18 +23,16 @@ interface FlashBagInterface extends SessionBagInterface
|
||||
/**
|
||||
* Adds a flash message for the given type.
|
||||
*
|
||||
* @param string $type
|
||||
* @param mixed $message
|
||||
* @param mixed $message
|
||||
*/
|
||||
public function add($type, $message);
|
||||
public function add(string $type, $message);
|
||||
|
||||
/**
|
||||
* Registers one or more messages for a given type.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string|array $messages
|
||||
*/
|
||||
public function set($type, $messages);
|
||||
public function set(string $type, $messages);
|
||||
|
||||
/**
|
||||
* Gets flash messages for a given type.
|
||||
@@ -44,7 +42,7 @@ interface FlashBagInterface extends SessionBagInterface
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function peek($type, array $default = []);
|
||||
public function peek(string $type, array $default = []);
|
||||
|
||||
/**
|
||||
* Gets all flash messages.
|
||||
@@ -56,12 +54,11 @@ interface FlashBagInterface extends SessionBagInterface
|
||||
/**
|
||||
* Gets and clears flash from the stack.
|
||||
*
|
||||
* @param string $type
|
||||
* @param array $default Default value if $type does not exist
|
||||
* @param array $default Default value if $type does not exist
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get($type, array $default = []);
|
||||
public function get(string $type, array $default = []);
|
||||
|
||||
/**
|
||||
* Gets and clears flashes from the stack.
|
||||
@@ -78,11 +75,9 @@ interface FlashBagInterface extends SessionBagInterface
|
||||
/**
|
||||
* Has flash messages for a given type?
|
||||
*
|
||||
* @param string $type
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has($type);
|
||||
public function has(string $type);
|
||||
|
||||
/**
|
||||
* Returns a list of all defined types.
|
||||
|
@@ -26,6 +26,8 @@ class_exists(SessionBagProxy::class);
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Drak <drak@zikula.org>
|
||||
*
|
||||
* @implements \IteratorAggregate<string, mixed>
|
||||
*/
|
||||
class Session implements SessionInterface, \IteratorAggregate, \Countable
|
||||
{
|
||||
@@ -35,10 +37,12 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
|
||||
private $attributeName;
|
||||
private $data = [];
|
||||
private $usageIndex = 0;
|
||||
private $usageReporter;
|
||||
|
||||
public function __construct(SessionStorageInterface $storage = null, AttributeBagInterface $attributes = null, FlashBagInterface $flashes = null)
|
||||
public function __construct(SessionStorageInterface $storage = null, AttributeBagInterface $attributes = null, FlashBagInterface $flashes = null, callable $usageReporter = null)
|
||||
{
|
||||
$this->storage = $storage ?? new NativeSessionStorage();
|
||||
$this->usageReporter = $usageReporter;
|
||||
|
||||
$attributes = $attributes ?? new AttributeBag();
|
||||
$this->attributeName = $attributes->getName();
|
||||
@@ -60,7 +64,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function has($name)
|
||||
public function has(string $name)
|
||||
{
|
||||
return $this->getAttributeBag()->has($name);
|
||||
}
|
||||
@@ -68,7 +72,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($name, $default = null)
|
||||
public function get(string $name, $default = null)
|
||||
{
|
||||
return $this->getAttributeBag()->get($name, $default);
|
||||
}
|
||||
@@ -76,7 +80,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set($name, $value)
|
||||
public function set(string $name, $value)
|
||||
{
|
||||
$this->getAttributeBag()->set($name, $value);
|
||||
}
|
||||
@@ -100,7 +104,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function remove($name)
|
||||
public function remove(string $name)
|
||||
{
|
||||
return $this->getAttributeBag()->remove($name);
|
||||
}
|
||||
@@ -124,7 +128,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
|
||||
/**
|
||||
* Returns an iterator for attributes.
|
||||
*
|
||||
* @return \ArrayIterator An \ArrayIterator instance
|
||||
* @return \ArrayIterator<string, mixed>
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getIterator()
|
||||
@@ -155,6 +159,9 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
|
||||
{
|
||||
if ($this->isStarted()) {
|
||||
++$this->usageIndex;
|
||||
if ($this->usageReporter && 0 <= $this->usageIndex) {
|
||||
($this->usageReporter)();
|
||||
}
|
||||
}
|
||||
foreach ($this->data as &$data) {
|
||||
if (!empty($data)) {
|
||||
@@ -168,7 +175,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function invalidate($lifetime = null)
|
||||
public function invalidate(int $lifetime = null)
|
||||
{
|
||||
$this->storage->clear();
|
||||
|
||||
@@ -178,7 +185,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function migrate($destroy = false, $lifetime = null)
|
||||
public function migrate(bool $destroy = false, int $lifetime = null)
|
||||
{
|
||||
return $this->storage->regenerate($destroy, $lifetime);
|
||||
}
|
||||
@@ -202,7 +209,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setId($id)
|
||||
public function setId(string $id)
|
||||
{
|
||||
if ($this->storage->getId() !== $id) {
|
||||
$this->storage->setId($id);
|
||||
@@ -220,7 +227,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setName($name)
|
||||
public function setName(string $name)
|
||||
{
|
||||
$this->storage->setName($name);
|
||||
}
|
||||
@@ -231,6 +238,9 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
|
||||
public function getMetadataBag()
|
||||
{
|
||||
++$this->usageIndex;
|
||||
if ($this->usageReporter && 0 <= $this->usageIndex) {
|
||||
($this->usageReporter)();
|
||||
}
|
||||
|
||||
return $this->storage->getMetadataBag();
|
||||
}
|
||||
@@ -240,13 +250,13 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
|
||||
*/
|
||||
public function registerBag(SessionBagInterface $bag)
|
||||
{
|
||||
$this->storage->registerBag(new SessionBagProxy($bag, $this->data, $this->usageIndex));
|
||||
$this->storage->registerBag(new SessionBagProxy($bag, $this->data, $this->usageIndex, $this->usageReporter));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBag($name)
|
||||
public function getBag(string $name)
|
||||
{
|
||||
$bag = $this->storage->getBag($name);
|
||||
|
||||
|
@@ -21,17 +21,22 @@ final class SessionBagProxy implements SessionBagInterface
|
||||
private $bag;
|
||||
private $data;
|
||||
private $usageIndex;
|
||||
private $usageReporter;
|
||||
|
||||
public function __construct(SessionBagInterface $bag, array &$data, ?int &$usageIndex)
|
||||
public function __construct(SessionBagInterface $bag, array &$data, ?int &$usageIndex, ?callable $usageReporter)
|
||||
{
|
||||
$this->bag = $bag;
|
||||
$this->data = &$data;
|
||||
$this->usageIndex = &$usageIndex;
|
||||
$this->usageReporter = $usageReporter;
|
||||
}
|
||||
|
||||
public function getBag(): SessionBagInterface
|
||||
{
|
||||
++$this->usageIndex;
|
||||
if ($this->usageReporter && 0 <= $this->usageIndex) {
|
||||
($this->usageReporter)();
|
||||
}
|
||||
|
||||
return $this->bag;
|
||||
}
|
||||
@@ -42,6 +47,9 @@ final class SessionBagProxy implements SessionBagInterface
|
||||
return true;
|
||||
}
|
||||
++$this->usageIndex;
|
||||
if ($this->usageReporter && 0 <= $this->usageIndex) {
|
||||
($this->usageReporter)();
|
||||
}
|
||||
|
||||
return empty($this->data[$this->bag->getStorageKey()]);
|
||||
}
|
||||
@@ -60,6 +68,10 @@ final class SessionBagProxy implements SessionBagInterface
|
||||
public function initialize(array &$array): void
|
||||
{
|
||||
++$this->usageIndex;
|
||||
if ($this->usageReporter && 0 <= $this->usageIndex) {
|
||||
($this->usageReporter)();
|
||||
}
|
||||
|
||||
$this->data[$this->bag->getStorageKey()] = &$array;
|
||||
|
||||
$this->bag->initialize($array);
|
||||
|
40
vendor/symfony/http-foundation/Session/SessionFactory.php
vendored
Normal file
40
vendor/symfony/http-foundation/Session/SessionFactory.php
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\Session;
|
||||
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageFactoryInterface;
|
||||
|
||||
// Help opcache.preload discover always-needed symbols
|
||||
class_exists(Session::class);
|
||||
|
||||
/**
|
||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
||||
*/
|
||||
class SessionFactory implements SessionFactoryInterface
|
||||
{
|
||||
private $requestStack;
|
||||
private $storageFactory;
|
||||
private $usageReporter;
|
||||
|
||||
public function __construct(RequestStack $requestStack, SessionStorageFactoryInterface $storageFactory, callable $usageReporter = null)
|
||||
{
|
||||
$this->requestStack = $requestStack;
|
||||
$this->storageFactory = $storageFactory;
|
||||
$this->usageReporter = $usageReporter;
|
||||
}
|
||||
|
||||
public function createSession(): SessionInterface
|
||||
{
|
||||
return new Session($this->storageFactory->createStorage($this->requestStack->getMainRequest()), null, null, $this->usageReporter);
|
||||
}
|
||||
}
|
20
vendor/symfony/http-foundation/Session/SessionFactoryInterface.php
vendored
Normal file
20
vendor/symfony/http-foundation/Session/SessionFactoryInterface.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\Session;
|
||||
|
||||
/**
|
||||
* @author Kevin Bond <kevinbond@gmail.com>
|
||||
*/
|
||||
interface SessionFactoryInterface
|
||||
{
|
||||
public function createSession(): SessionInterface;
|
||||
}
|
@@ -38,10 +38,8 @@ interface SessionInterface
|
||||
|
||||
/**
|
||||
* Sets the session ID.
|
||||
*
|
||||
* @param string $id
|
||||
*/
|
||||
public function setId($id);
|
||||
public function setId(string $id);
|
||||
|
||||
/**
|
||||
* Returns the session name.
|
||||
@@ -52,10 +50,8 @@ interface SessionInterface
|
||||
|
||||
/**
|
||||
* Sets the session name.
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName($name);
|
||||
public function setName(string $name);
|
||||
|
||||
/**
|
||||
* Invalidates the current session.
|
||||
@@ -70,7 +66,7 @@ interface SessionInterface
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function invalidate($lifetime = null);
|
||||
public function invalidate(int $lifetime = null);
|
||||
|
||||
/**
|
||||
* Migrates the current session to a new session id while maintaining all
|
||||
@@ -84,7 +80,7 @@ interface SessionInterface
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function migrate($destroy = false, $lifetime = null);
|
||||
public function migrate(bool $destroy = false, int $lifetime = null);
|
||||
|
||||
/**
|
||||
* Force the session to be saved and closed.
|
||||
@@ -98,29 +94,25 @@ interface SessionInterface
|
||||
/**
|
||||
* Checks if an attribute is defined.
|
||||
*
|
||||
* @param string $name The attribute name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has($name);
|
||||
public function has(string $name);
|
||||
|
||||
/**
|
||||
* Returns an attribute.
|
||||
*
|
||||
* @param string $name The attribute name
|
||||
* @param mixed $default The default value if not found
|
||||
* @param mixed $default The default value if not found
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($name, $default = null);
|
||||
public function get(string $name, $default = null);
|
||||
|
||||
/**
|
||||
* Sets an attribute.
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function set($name, $value);
|
||||
public function set(string $name, $value);
|
||||
|
||||
/**
|
||||
* Returns attributes.
|
||||
@@ -137,11 +129,9 @@ interface SessionInterface
|
||||
/**
|
||||
* Removes an attribute.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return mixed The removed value or null when it does not exist
|
||||
*/
|
||||
public function remove($name);
|
||||
public function remove(string $name);
|
||||
|
||||
/**
|
||||
* Clears all attributes.
|
||||
@@ -163,11 +153,9 @@ interface SessionInterface
|
||||
/**
|
||||
* Gets a bag instance by name.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return SessionBagInterface
|
||||
*/
|
||||
public function getBag($name);
|
||||
public function getBag(string $name);
|
||||
|
||||
/**
|
||||
* Gets session meta.
|
||||
|
@@ -43,26 +43,19 @@ abstract class AbstractSessionHandler implements \SessionHandlerInterface, \Sess
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sessionId
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function doRead($sessionId);
|
||||
abstract protected function doRead(string $sessionId);
|
||||
|
||||
/**
|
||||
* @param string $sessionId
|
||||
* @param string $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function doWrite($sessionId, $data);
|
||||
abstract protected function doWrite(string $sessionId, string $data);
|
||||
|
||||
/**
|
||||
* @param string $sessionId
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function doDestroy($sessionId);
|
||||
abstract protected function doDestroy(string $sessionId);
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
|
42
vendor/symfony/http-foundation/Session/Storage/Handler/IdentityMarshaller.php
vendored
Normal file
42
vendor/symfony/http-foundation/Session/Storage/Handler/IdentityMarshaller.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
|
||||
|
||||
use Symfony\Component\Cache\Marshaller\MarshallerInterface;
|
||||
|
||||
/**
|
||||
* @author Ahmed TAILOULOUTE <ahmed.tailouloute@gmail.com>
|
||||
*/
|
||||
class IdentityMarshaller implements MarshallerInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function marshall(array $values, ?array &$failed): array
|
||||
{
|
||||
foreach ($values as $key => $value) {
|
||||
if (!\is_string($value)) {
|
||||
throw new \LogicException(sprintf('%s accepts only string as data.', __METHOD__));
|
||||
}
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function unmarshall(string $value): string
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
}
|
108
vendor/symfony/http-foundation/Session/Storage/Handler/MarshallingSessionHandler.php
vendored
Normal file
108
vendor/symfony/http-foundation/Session/Storage/Handler/MarshallingSessionHandler.php
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
|
||||
|
||||
use Symfony\Component\Cache\Marshaller\MarshallerInterface;
|
||||
|
||||
/**
|
||||
* @author Ahmed TAILOULOUTE <ahmed.tailouloute@gmail.com>
|
||||
*/
|
||||
class MarshallingSessionHandler implements \SessionHandlerInterface, \SessionUpdateTimestampHandlerInterface
|
||||
{
|
||||
private $handler;
|
||||
private $marshaller;
|
||||
|
||||
public function __construct(AbstractSessionHandler $handler, MarshallerInterface $marshaller)
|
||||
{
|
||||
$this->handler = $handler;
|
||||
$this->marshaller = $marshaller;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function open($savePath, $name)
|
||||
{
|
||||
return $this->handler->open($savePath, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function close()
|
||||
{
|
||||
return $this->handler->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function destroy($sessionId)
|
||||
{
|
||||
return $this->handler->destroy($sessionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|false
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function gc($maxlifetime)
|
||||
{
|
||||
return $this->handler->gc($maxlifetime);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function read($sessionId)
|
||||
{
|
||||
return $this->marshaller->unmarshall($this->handler->read($sessionId));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function write($sessionId, $data)
|
||||
{
|
||||
$failed = [];
|
||||
$marshalledData = $this->marshaller->marshall(['data' => $data], $failed);
|
||||
|
||||
if (isset($failed['data'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->handler->write($sessionId, $marshalledData['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function validateId($sessionId)
|
||||
{
|
||||
return $this->handler->validateId($sessionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function updateTimestamp($sessionId, $data)
|
||||
{
|
||||
return $this->handler->updateTimestamp($sessionId, $data);
|
||||
}
|
||||
}
|
@@ -38,7 +38,7 @@ class MemcachedSessionHandler extends AbstractSessionHandler
|
||||
*
|
||||
* List of available options:
|
||||
* * prefix: The prefix to use for the memcached keys in order to avoid collision
|
||||
* * expiretime: The time to live in seconds.
|
||||
* * ttl: The time to live in seconds.
|
||||
*
|
||||
* @throws \InvalidArgumentException When unsupported options are passed
|
||||
*/
|
||||
@@ -46,11 +46,11 @@ class MemcachedSessionHandler extends AbstractSessionHandler
|
||||
{
|
||||
$this->memcached = $memcached;
|
||||
|
||||
if ($diff = array_diff(array_keys($options), ['prefix', 'expiretime'])) {
|
||||
if ($diff = array_diff(array_keys($options), ['prefix', 'expiretime', 'ttl'])) {
|
||||
throw new \InvalidArgumentException(sprintf('The following options are not supported "%s".', implode(', ', $diff)));
|
||||
}
|
||||
|
||||
$this->ttl = isset($options['expiretime']) ? (int) $options['expiretime'] : 86400;
|
||||
$this->ttl = $options['expiretime'] ?? $options['ttl'] ?? null;
|
||||
$this->prefix = $options['prefix'] ?? 'sf2s';
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ class MemcachedSessionHandler extends AbstractSessionHandler
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doRead($sessionId)
|
||||
protected function doRead(string $sessionId)
|
||||
{
|
||||
return $this->memcached->get($this->prefix.$sessionId) ?: '';
|
||||
}
|
||||
@@ -77,7 +77,7 @@ class MemcachedSessionHandler extends AbstractSessionHandler
|
||||
#[\ReturnTypeWillChange]
|
||||
public function updateTimestamp($sessionId, $data)
|
||||
{
|
||||
$this->memcached->touch($this->prefix.$sessionId, time() + $this->ttl);
|
||||
$this->memcached->touch($this->prefix.$sessionId, $this->getCompatibleTtl());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -85,15 +85,28 @@ class MemcachedSessionHandler extends AbstractSessionHandler
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doWrite($sessionId, $data)
|
||||
protected function doWrite(string $sessionId, string $data)
|
||||
{
|
||||
return $this->memcached->set($this->prefix.$sessionId, $data, time() + $this->ttl);
|
||||
return $this->memcached->set($this->prefix.$sessionId, $data, $this->getCompatibleTtl());
|
||||
}
|
||||
|
||||
private function getCompatibleTtl(): int
|
||||
{
|
||||
$ttl = (int) ($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;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDestroy($sessionId)
|
||||
protected function doDestroy(string $sessionId)
|
||||
{
|
||||
$result = $this->memcached->delete($this->prefix.$sessionId);
|
||||
|
||||
|
@@ -22,7 +22,14 @@ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
|
||||
*/
|
||||
class MigratingSessionHandler implements \SessionHandlerInterface, \SessionUpdateTimestampHandlerInterface
|
||||
{
|
||||
/**
|
||||
* @var \SessionHandlerInterface&\SessionUpdateTimestampHandlerInterface
|
||||
*/
|
||||
private $currentHandler;
|
||||
|
||||
/**
|
||||
* @var \SessionHandlerInterface&\SessionUpdateTimestampHandlerInterface
|
||||
*/
|
||||
private $writeOnlyHandler;
|
||||
|
||||
public function __construct(\SessionHandlerInterface $currentHandler, \SessionHandlerInterface $writeOnlyHandler)
|
||||
|
@@ -11,6 +11,11 @@
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
|
||||
|
||||
use MongoDB\BSON\Binary;
|
||||
use MongoDB\BSON\UTCDateTime;
|
||||
use MongoDB\Client;
|
||||
use MongoDB\Collection;
|
||||
|
||||
/**
|
||||
* Session handler using the mongodb/mongodb package and MongoDB driver extension.
|
||||
*
|
||||
@@ -24,7 +29,7 @@ class MongoDbSessionHandler extends AbstractSessionHandler
|
||||
private $mongo;
|
||||
|
||||
/**
|
||||
* @var \MongoDB\Collection
|
||||
* @var Collection
|
||||
*/
|
||||
private $collection;
|
||||
|
||||
@@ -63,7 +68,7 @@ class MongoDbSessionHandler extends AbstractSessionHandler
|
||||
*
|
||||
* @throws \InvalidArgumentException When "database" or "collection" not provided
|
||||
*/
|
||||
public function __construct(\MongoDB\Client $mongo, array $options)
|
||||
public function __construct(Client $mongo, array $options)
|
||||
{
|
||||
if (!isset($options['database']) || !isset($options['collection'])) {
|
||||
throw new \InvalidArgumentException('You must provide the "database" and "collection" option for MongoDBSessionHandler.');
|
||||
@@ -91,7 +96,7 @@ class MongoDbSessionHandler extends AbstractSessionHandler
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDestroy($sessionId)
|
||||
protected function doDestroy(string $sessionId)
|
||||
{
|
||||
$this->getCollection()->deleteOne([
|
||||
$this->options['id_field'] => $sessionId,
|
||||
@@ -107,21 +112,21 @@ class MongoDbSessionHandler extends AbstractSessionHandler
|
||||
public function gc($maxlifetime)
|
||||
{
|
||||
return $this->getCollection()->deleteMany([
|
||||
$this->options['expiry_field'] => ['$lt' => new \MongoDB\BSON\UTCDateTime()],
|
||||
$this->options['expiry_field'] => ['$lt' => new UTCDateTime()],
|
||||
])->getDeletedCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doWrite($sessionId, $data)
|
||||
protected function doWrite(string $sessionId, string $data)
|
||||
{
|
||||
$expiry = new \MongoDB\BSON\UTCDateTime((time() + (int) \ini_get('session.gc_maxlifetime')) * 1000);
|
||||
$expiry = new UTCDateTime((time() + (int) \ini_get('session.gc_maxlifetime')) * 1000);
|
||||
|
||||
$fields = [
|
||||
$this->options['time_field'] => new \MongoDB\BSON\UTCDateTime(),
|
||||
$this->options['time_field'] => new UTCDateTime(),
|
||||
$this->options['expiry_field'] => $expiry,
|
||||
$this->options['data_field'] => new \MongoDB\BSON\Binary($data, \MongoDB\BSON\Binary::TYPE_OLD_BINARY),
|
||||
$this->options['data_field'] => new Binary($data, Binary::TYPE_OLD_BINARY),
|
||||
];
|
||||
|
||||
$this->getCollection()->updateOne(
|
||||
@@ -139,12 +144,12 @@ class MongoDbSessionHandler extends AbstractSessionHandler
|
||||
#[\ReturnTypeWillChange]
|
||||
public function updateTimestamp($sessionId, $data)
|
||||
{
|
||||
$expiry = new \MongoDB\BSON\UTCDateTime((time() + (int) \ini_get('session.gc_maxlifetime')) * 1000);
|
||||
$expiry = new UTCDateTime((time() + (int) \ini_get('session.gc_maxlifetime')) * 1000);
|
||||
|
||||
$this->getCollection()->updateOne(
|
||||
[$this->options['id_field'] => $sessionId],
|
||||
['$set' => [
|
||||
$this->options['time_field'] => new \MongoDB\BSON\UTCDateTime(),
|
||||
$this->options['time_field'] => new UTCDateTime(),
|
||||
$this->options['expiry_field'] => $expiry,
|
||||
]]
|
||||
);
|
||||
@@ -155,11 +160,11 @@ class MongoDbSessionHandler extends AbstractSessionHandler
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doRead($sessionId)
|
||||
protected function doRead(string $sessionId)
|
||||
{
|
||||
$dbData = $this->getCollection()->findOne([
|
||||
$this->options['id_field'] => $sessionId,
|
||||
$this->options['expiry_field'] => ['$gte' => new \MongoDB\BSON\UTCDateTime()],
|
||||
$this->options['expiry_field'] => ['$gte' => new UTCDateTime()],
|
||||
]);
|
||||
|
||||
if (null === $dbData) {
|
||||
@@ -169,7 +174,7 @@ class MongoDbSessionHandler extends AbstractSessionHandler
|
||||
return $dbData[$this->options['data_field']]->getData();
|
||||
}
|
||||
|
||||
private function getCollection(): \MongoDB\Collection
|
||||
private function getCollection(): Collection
|
||||
{
|
||||
if (null === $this->collection) {
|
||||
$this->collection = $this->mongo->selectCollection($this->options['database'], $this->options['collection']);
|
||||
@@ -179,7 +184,7 @@ class MongoDbSessionHandler extends AbstractSessionHandler
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MongoDB\Client
|
||||
* @return Client
|
||||
*/
|
||||
protected function getMongo()
|
||||
{
|
||||
|
@@ -39,7 +39,7 @@ class NullSessionHandler extends AbstractSessionHandler
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doRead($sessionId)
|
||||
protected function doRead(string $sessionId)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
@@ -56,7 +56,7 @@ class NullSessionHandler extends AbstractSessionHandler
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doWrite($sessionId, $data)
|
||||
protected function doWrite(string $sessionId, string $data)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -64,7 +64,7 @@ class NullSessionHandler extends AbstractSessionHandler
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDestroy($sessionId)
|
||||
protected function doDestroy(string $sessionId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@@ -73,57 +73,67 @@ class PdoSessionHandler extends AbstractSessionHandler
|
||||
private $pdo;
|
||||
|
||||
/**
|
||||
* @var string|false|null DSN string or null for session.save_path or false when lazy connection disabled
|
||||
* DSN string or null for session.save_path or false when lazy connection disabled.
|
||||
*
|
||||
* @var string|false|null
|
||||
*/
|
||||
private $dsn = false;
|
||||
|
||||
/**
|
||||
* @var string Database driver
|
||||
* @var string|null
|
||||
*/
|
||||
private $driver;
|
||||
|
||||
/**
|
||||
* @var string Table name
|
||||
* @var string
|
||||
*/
|
||||
private $table = 'sessions';
|
||||
|
||||
/**
|
||||
* @var string Column for session id
|
||||
* @var string
|
||||
*/
|
||||
private $idCol = 'sess_id';
|
||||
|
||||
/**
|
||||
* @var string Column for session data
|
||||
* @var string
|
||||
*/
|
||||
private $dataCol = 'sess_data';
|
||||
|
||||
/**
|
||||
* @var string Column for lifetime
|
||||
* @var string
|
||||
*/
|
||||
private $lifetimeCol = 'sess_lifetime';
|
||||
|
||||
/**
|
||||
* @var string Column for timestamp
|
||||
* @var string
|
||||
*/
|
||||
private $timeCol = 'sess_time';
|
||||
|
||||
/**
|
||||
* @var string Username when lazy-connect
|
||||
* Username when lazy-connect.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $username = '';
|
||||
|
||||
/**
|
||||
* @var string Password when lazy-connect
|
||||
* Password when lazy-connect.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $password = '';
|
||||
|
||||
/**
|
||||
* @var array Connection options when lazy-connect
|
||||
* Connection options when lazy-connect.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $connectionOptions = [];
|
||||
|
||||
/**
|
||||
* @var int The strategy for locking, see constants
|
||||
* The strategy for locking, see constants.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $lockMode = self::LOCK_TRANSACTIONAL;
|
||||
|
||||
@@ -135,17 +145,23 @@ class PdoSessionHandler extends AbstractSessionHandler
|
||||
private $unlockStatements = [];
|
||||
|
||||
/**
|
||||
* @var bool True when the current session exists but expired according to session.gc_maxlifetime
|
||||
* True when the current session exists but expired according to session.gc_maxlifetime.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $sessionExpired = false;
|
||||
|
||||
/**
|
||||
* @var bool Whether a transaction is active
|
||||
* Whether a transaction is active.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $inTransaction = false;
|
||||
|
||||
/**
|
||||
* @var bool Whether gc() has been called
|
||||
* Whether gc() has been called.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $gcCalled = false;
|
||||
|
||||
@@ -252,7 +268,7 @@ class PdoSessionHandler extends AbstractSessionHandler
|
||||
*
|
||||
* Can be used to distinguish between a new session and one that expired due to inactivity.
|
||||
*
|
||||
* @return bool Whether current session expired
|
||||
* @return bool
|
||||
*/
|
||||
public function isSessionExpired()
|
||||
{
|
||||
@@ -305,7 +321,7 @@ class PdoSessionHandler extends AbstractSessionHandler
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDestroy($sessionId)
|
||||
protected function doDestroy(string $sessionId)
|
||||
{
|
||||
// delete the record associated with this id
|
||||
$sql = "DELETE FROM $this->table WHERE $this->idCol = :id";
|
||||
@@ -326,7 +342,7 @@ class PdoSessionHandler extends AbstractSessionHandler
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doWrite($sessionId, $data)
|
||||
protected function doWrite(string $sessionId, string $data)
|
||||
{
|
||||
$maxlifetime = (int) \ini_get('session.gc_maxlifetime');
|
||||
|
||||
@@ -430,6 +446,7 @@ class PdoSessionHandler extends AbstractSessionHandler
|
||||
|
||||
if (false !== $this->dsn) {
|
||||
$this->pdo = null; // only close lazy-connection
|
||||
$this->driver = null;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -491,10 +508,32 @@ class PdoSessionHandler extends AbstractSessionHandler
|
||||
$driver = substr($driver, 4);
|
||||
}
|
||||
|
||||
$dsn = null;
|
||||
switch ($driver) {
|
||||
case 'mysql':
|
||||
$dsn = 'mysql:';
|
||||
if ('' !== ($params['query'] ?? '')) {
|
||||
$queryParams = [];
|
||||
parse_str($params['query'], $queryParams);
|
||||
if ('' !== ($queryParams['charset'] ?? '')) {
|
||||
$dsn .= 'charset='.$queryParams['charset'].';';
|
||||
}
|
||||
|
||||
if ('' !== ($queryParams['unix_socket'] ?? '')) {
|
||||
$dsn .= 'unix_socket='.$queryParams['unix_socket'].';';
|
||||
|
||||
if (isset($params['path'])) {
|
||||
$dbName = substr($params['path'], 1); // Remove the leading slash
|
||||
$dsn .= 'dbname='.$dbName.';';
|
||||
}
|
||||
|
||||
return $dsn;
|
||||
}
|
||||
}
|
||||
// If "unix_socket" is not in the query, we continue with the same process as pgsql
|
||||
// no break
|
||||
case 'pgsql':
|
||||
$dsn = $driver.':';
|
||||
$dsn ?? $dsn = 'pgsql:';
|
||||
|
||||
if (isset($params['host']) && '' !== $params['host']) {
|
||||
$dsn .= 'host='.$params['host'].';';
|
||||
@@ -611,11 +650,9 @@ class PdoSessionHandler extends AbstractSessionHandler
|
||||
* We need to make sure we do not return session data that is already considered garbage according
|
||||
* to the session.gc_maxlifetime setting because gc() is called after read() and only sometimes.
|
||||
*
|
||||
* @param string $sessionId Session ID
|
||||
*
|
||||
* @return string The session data
|
||||
* @return string
|
||||
*/
|
||||
protected function doRead($sessionId)
|
||||
protected function doRead(string $sessionId)
|
||||
{
|
||||
if (self::LOCK_ADVISORY === $this->lockMode) {
|
||||
$this->unlockStatements[] = $this->doAdvisoryLock($sessionId);
|
||||
|
@@ -54,7 +54,7 @@ class RedisSessionHandler extends AbstractSessionHandler
|
||||
!$redis instanceof RedisProxy &&
|
||||
!$redis instanceof RedisClusterProxy
|
||||
) {
|
||||
throw new \InvalidArgumentException(sprintf('"%s()" expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\ClientInterface, "%s" given.', __METHOD__, \is_object($redis) ? \get_class($redis) : \gettype($redis)));
|
||||
throw new \InvalidArgumentException(sprintf('"%s()" expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\ClientInterface, "%s" given.', __METHOD__, get_debug_type($redis)));
|
||||
}
|
||||
|
||||
if ($diff = array_diff(array_keys($options), ['prefix', 'ttl'])) {
|
||||
@@ -69,7 +69,7 @@ class RedisSessionHandler extends AbstractSessionHandler
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doRead($sessionId): string
|
||||
protected function doRead(string $sessionId): string
|
||||
{
|
||||
return $this->redis->get($this->prefix.$sessionId) ?: '';
|
||||
}
|
||||
@@ -77,7 +77,7 @@ class RedisSessionHandler extends AbstractSessionHandler
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doWrite($sessionId, $data): bool
|
||||
protected function doWrite(string $sessionId, string $data): bool
|
||||
{
|
||||
$result = $this->redis->setEx($this->prefix.$sessionId, (int) ($this->ttl ?? \ini_get('session.gc_maxlifetime')), $data);
|
||||
|
||||
@@ -87,9 +87,21 @@ class RedisSessionHandler extends AbstractSessionHandler
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDestroy($sessionId): bool
|
||||
protected function doDestroy(string $sessionId): bool
|
||||
{
|
||||
$this->redis->del($this->prefix.$sessionId);
|
||||
static $unlink = true;
|
||||
|
||||
if ($unlink) {
|
||||
try {
|
||||
$unlink = false !== $this->redis->unlink($this->prefix.$sessionId);
|
||||
} catch (\Throwable $e) {
|
||||
$unlink = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$unlink) {
|
||||
$this->redis->del($this->prefix.$sessionId);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -27,7 +27,11 @@ class SessionHandlerFactory
|
||||
public static function createHandler($connection): AbstractSessionHandler
|
||||
{
|
||||
if (!\is_string($connection) && !\is_object($connection)) {
|
||||
throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a string or a connection object, "%s" given.', __METHOD__, \gettype($connection)));
|
||||
throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a string or a connection object, "%s" given.', __METHOD__, get_debug_type($connection)));
|
||||
}
|
||||
|
||||
if ($options = \is_string($connection) ? parse_url($connection) : false) {
|
||||
parse_str($options['query'] ?? '', $options);
|
||||
}
|
||||
|
||||
switch (true) {
|
||||
@@ -46,7 +50,7 @@ class SessionHandlerFactory
|
||||
return new PdoSessionHandler($connection);
|
||||
|
||||
case !\is_string($connection):
|
||||
throw new \InvalidArgumentException(sprintf('Unsupported Connection: "%s".', \get_class($connection)));
|
||||
throw new \InvalidArgumentException(sprintf('Unsupported Connection: "%s".', get_debug_type($connection)));
|
||||
case str_starts_with($connection, 'file://'):
|
||||
$savePath = substr($connection, 7);
|
||||
|
||||
@@ -61,7 +65,7 @@ class SessionHandlerFactory
|
||||
$handlerClass = str_starts_with($connection, 'memcached:') ? MemcachedSessionHandler::class : RedisSessionHandler::class;
|
||||
$connection = AbstractAdapter::createConnection($connection, ['lazy' => true]);
|
||||
|
||||
return new $handlerClass($connection);
|
||||
return new $handlerClass($connection, array_intersect_key($options ?: [], ['prefix' => 1, 'ttl' => 1]));
|
||||
|
||||
case str_starts_with($connection, 'pdo_oci://'):
|
||||
if (!class_exists(DriverManager::class)) {
|
||||
@@ -79,7 +83,7 @@ class SessionHandlerFactory
|
||||
case str_starts_with($connection, 'sqlsrv://'):
|
||||
case str_starts_with($connection, 'sqlite://'):
|
||||
case str_starts_with($connection, 'sqlite3://'):
|
||||
return new PdoSessionHandler($connection);
|
||||
return new PdoSessionHandler($connection, $options ?: []);
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException(sprintf('Unsupported Connection: "%s".', $connection));
|
||||
|
@@ -24,7 +24,7 @@ class StrictSessionHandler extends AbstractSessionHandler
|
||||
public function __construct(\SessionHandlerInterface $handler)
|
||||
{
|
||||
if ($handler instanceof \SessionUpdateTimestampHandlerInterface) {
|
||||
throw new \LogicException(sprintf('"%s" is already an instance of "SessionUpdateTimestampHandlerInterface", you cannot wrap it with "%s".', \get_class($handler), self::class));
|
||||
throw new \LogicException(sprintf('"%s" is already an instance of "SessionUpdateTimestampHandlerInterface", you cannot wrap it with "%s".', get_debug_type($handler), self::class));
|
||||
}
|
||||
|
||||
$this->handler = $handler;
|
||||
@@ -54,7 +54,7 @@ class StrictSessionHandler extends AbstractSessionHandler
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doRead($sessionId)
|
||||
protected function doRead(string $sessionId)
|
||||
{
|
||||
return $this->handler->read($sessionId);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ class StrictSessionHandler extends AbstractSessionHandler
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doWrite($sessionId, $data)
|
||||
protected function doWrite(string $sessionId, string $data)
|
||||
{
|
||||
return $this->handler->write($sessionId, $data);
|
||||
}
|
||||
@@ -91,7 +91,7 @@ class StrictSessionHandler extends AbstractSessionHandler
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDestroy($sessionId)
|
||||
protected function doDestroy(string $sessionId)
|
||||
{
|
||||
$this->doDestroy = false;
|
||||
|
||||
|
@@ -100,7 +100,7 @@ class MetadataBag implements SessionBagInterface
|
||||
* to expire with browser session. Time is in seconds, and is
|
||||
* not a Unix timestamp.
|
||||
*/
|
||||
public function stampNew($lifetime = null)
|
||||
public function stampNew(int $lifetime = null)
|
||||
{
|
||||
$this->stampCreated($lifetime);
|
||||
}
|
||||
@@ -139,6 +139,7 @@ class MetadataBag implements SessionBagInterface
|
||||
public function clear()
|
||||
{
|
||||
// nothing to do
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,10 +152,8 @@ class MetadataBag implements SessionBagInterface
|
||||
|
||||
/**
|
||||
* Sets name.
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName($name)
|
||||
public function setName(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
@@ -94,7 +94,7 @@ class MockArraySessionStorage implements SessionStorageInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function regenerate($destroy = false, $lifetime = null)
|
||||
public function regenerate(bool $destroy = false, int $lifetime = null)
|
||||
{
|
||||
if (!$this->started) {
|
||||
$this->start();
|
||||
@@ -117,7 +117,7 @@ class MockArraySessionStorage implements SessionStorageInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setId($id)
|
||||
public function setId(string $id)
|
||||
{
|
||||
if ($this->started) {
|
||||
throw new \LogicException('Cannot set session ID after the session has started.');
|
||||
@@ -137,7 +137,7 @@ class MockArraySessionStorage implements SessionStorageInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setName($name)
|
||||
public function setName(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
@@ -183,7 +183,7 @@ class MockArraySessionStorage implements SessionStorageInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBag($name)
|
||||
public function getBag(string $name)
|
||||
{
|
||||
if (!isset($this->bags[$name])) {
|
||||
throw new \InvalidArgumentException(sprintf('The SessionBagInterface "%s" is not registered.', $name));
|
||||
|
@@ -28,8 +28,7 @@ class MockFileSessionStorage extends MockArraySessionStorage
|
||||
private $savePath;
|
||||
|
||||
/**
|
||||
* @param string $savePath Path of directory to save session files
|
||||
* @param string $name Session name
|
||||
* @param string|null $savePath Path of directory to save session files
|
||||
*/
|
||||
public function __construct(string $savePath = null, string $name = 'MOCKSESSID', MetadataBag $metaBag = null)
|
||||
{
|
||||
@@ -69,7 +68,7 @@ class MockFileSessionStorage extends MockArraySessionStorage
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function regenerate($destroy = false, $lifetime = null)
|
||||
public function regenerate(bool $destroy = false, int $lifetime = null)
|
||||
{
|
||||
if (!$this->started) {
|
||||
$this->start();
|
||||
|
42
vendor/symfony/http-foundation/Session/Storage/MockFileSessionStorageFactory.php
vendored
Normal file
42
vendor/symfony/http-foundation/Session/Storage/MockFileSessionStorageFactory.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
// Help opcache.preload discover always-needed symbols
|
||||
class_exists(MockFileSessionStorage::class);
|
||||
|
||||
/**
|
||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
||||
*/
|
||||
class MockFileSessionStorageFactory implements SessionStorageFactoryInterface
|
||||
{
|
||||
private $savePath;
|
||||
private $name;
|
||||
private $metaBag;
|
||||
|
||||
/**
|
||||
* @see MockFileSessionStorage constructor.
|
||||
*/
|
||||
public function __construct(string $savePath = null, string $name = 'MOCKSESSID', MetadataBag $metaBag = null)
|
||||
{
|
||||
$this->savePath = $savePath;
|
||||
$this->name = $name;
|
||||
$this->metaBag = $metaBag;
|
||||
}
|
||||
|
||||
public function createStorage(?Request $request): SessionStorageInterface
|
||||
{
|
||||
return new MockFileSessionStorage($this->savePath, $this->name, $this->metaBag);
|
||||
}
|
||||
}
|
@@ -90,13 +90,6 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||
* use_cookies, "1"
|
||||
* use_only_cookies, "1"
|
||||
* use_trans_sid, "0"
|
||||
* upload_progress.enabled, "1"
|
||||
* upload_progress.cleanup, "1"
|
||||
* upload_progress.prefix, "upload_progress_"
|
||||
* upload_progress.name, "PHP_SESSION_UPLOAD_PROGRESS"
|
||||
* upload_progress.freq, "1%"
|
||||
* upload_progress.min-freq, "1"
|
||||
* url_rewriter.tags, "a=href,area=href,frame=src,form=,fieldset="
|
||||
* sid_length, "32"
|
||||
* sid_bits_per_character, "5"
|
||||
* trans_sid_hosts, $_SERVER['HTTP_HOST']
|
||||
@@ -216,7 +209,7 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setId($id)
|
||||
public function setId(string $id)
|
||||
{
|
||||
$this->saveHandler->setId($id);
|
||||
}
|
||||
@@ -232,7 +225,7 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setName($name)
|
||||
public function setName(string $name)
|
||||
{
|
||||
$this->saveHandler->setName($name);
|
||||
}
|
||||
@@ -240,7 +233,7 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function regenerate($destroy = false, $lifetime = null)
|
||||
public function regenerate(bool $destroy = false, int $lifetime = null)
|
||||
{
|
||||
// Cannot regenerate the session ID for non-active sessions.
|
||||
if (\PHP_SESSION_ACTIVE !== session_status()) {
|
||||
@@ -347,7 +340,7 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBag($name)
|
||||
public function getBag(string $name)
|
||||
{
|
||||
if (!isset($this->bags[$name])) {
|
||||
throw new \InvalidArgumentException(sprintf('The SessionBagInterface "%s" is not registered.', $name));
|
||||
@@ -419,6 +412,13 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||
|
||||
foreach ($options as $key => $value) {
|
||||
if (isset($validOptions[$key])) {
|
||||
if (str_starts_with($key, 'upload_progress.')) {
|
||||
trigger_deprecation('symfony/http-foundation', '5.4', 'Support for the "%s" session option is deprecated. The settings prefixed with "session.upload_progress." can not be changed at runtime.', $key);
|
||||
continue;
|
||||
}
|
||||
if ('url_rewriter.tags' === $key) {
|
||||
trigger_deprecation('symfony/http-foundation', '5.4', 'Support for the "%s" session option is deprecated. Use "trans_sid_tags" instead.', $key);
|
||||
}
|
||||
if ('cookie_samesite' === $key && \PHP_VERSION_ID < 70300) {
|
||||
// PHP < 7.3 does not support same_site cookies. We will emulate it in
|
||||
// the start() method instead.
|
||||
|
49
vendor/symfony/http-foundation/Session/Storage/NativeSessionStorageFactory.php
vendored
Normal file
49
vendor/symfony/http-foundation/Session/Storage/NativeSessionStorageFactory.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
// Help opcache.preload discover always-needed symbols
|
||||
class_exists(NativeSessionStorage::class);
|
||||
|
||||
/**
|
||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
||||
*/
|
||||
class NativeSessionStorageFactory implements SessionStorageFactoryInterface
|
||||
{
|
||||
private $options;
|
||||
private $handler;
|
||||
private $metaBag;
|
||||
private $secure;
|
||||
|
||||
/**
|
||||
* @see NativeSessionStorage constructor.
|
||||
*/
|
||||
public function __construct(array $options = [], $handler = null, MetadataBag $metaBag = null, bool $secure = false)
|
||||
{
|
||||
$this->options = $options;
|
||||
$this->handler = $handler;
|
||||
$this->metaBag = $metaBag;
|
||||
$this->secure = $secure;
|
||||
}
|
||||
|
||||
public function createStorage(?Request $request): SessionStorageInterface
|
||||
{
|
||||
$storage = new NativeSessionStorage($this->options, $this->handler, $this->metaBag);
|
||||
if ($this->secure && $request && $request->isSecure()) {
|
||||
$storage->setOptions(['cookie_secure' => true]);
|
||||
}
|
||||
|
||||
return $storage;
|
||||
}
|
||||
}
|
47
vendor/symfony/http-foundation/Session/Storage/PhpBridgeSessionStorageFactory.php
vendored
Normal file
47
vendor/symfony/http-foundation/Session/Storage/PhpBridgeSessionStorageFactory.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
// Help opcache.preload discover always-needed symbols
|
||||
class_exists(PhpBridgeSessionStorage::class);
|
||||
|
||||
/**
|
||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
||||
*/
|
||||
class PhpBridgeSessionStorageFactory implements SessionStorageFactoryInterface
|
||||
{
|
||||
private $handler;
|
||||
private $metaBag;
|
||||
private $secure;
|
||||
|
||||
/**
|
||||
* @see PhpBridgeSessionStorage constructor.
|
||||
*/
|
||||
public function __construct($handler = null, MetadataBag $metaBag = null, bool $secure = false)
|
||||
{
|
||||
$this->handler = $handler;
|
||||
$this->metaBag = $metaBag;
|
||||
$this->secure = $secure;
|
||||
}
|
||||
|
||||
public function createStorage(?Request $request): SessionStorageInterface
|
||||
{
|
||||
$storage = new PhpBridgeSessionStorage($this->handler, $this->metaBag);
|
||||
if ($this->secure && $request && $request->isSecure()) {
|
||||
$storage->setOptions(['cookie_secure' => true]);
|
||||
}
|
||||
|
||||
return $storage;
|
||||
}
|
||||
}
|
@@ -81,11 +81,9 @@ abstract class AbstractProxy
|
||||
/**
|
||||
* Sets the session ID.
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function setId($id)
|
||||
public function setId(string $id)
|
||||
{
|
||||
if ($this->isActive()) {
|
||||
throw new \LogicException('Cannot change the ID of an active session.');
|
||||
@@ -107,11 +105,9 @@ abstract class AbstractProxy
|
||||
/**
|
||||
* Sets the session name.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function setName($name)
|
||||
public function setName(string $name)
|
||||
{
|
||||
if ($this->isActive()) {
|
||||
throw new \LogicException('Cannot change the name of an active session.');
|
||||
|
38
vendor/symfony/http-foundation/Session/Storage/ServiceSessionFactory.php
vendored
Normal file
38
vendor/symfony/http-foundation/Session/Storage/ServiceSessionFactory.php
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
||||
*
|
||||
* @internal to be removed in Symfony 6
|
||||
*/
|
||||
final class ServiceSessionFactory implements SessionStorageFactoryInterface
|
||||
{
|
||||
private $storage;
|
||||
|
||||
public function __construct(SessionStorageInterface $storage)
|
||||
{
|
||||
$this->storage = $storage;
|
||||
}
|
||||
|
||||
public function createStorage(?Request $request): SessionStorageInterface
|
||||
{
|
||||
if ($this->storage instanceof NativeSessionStorage && $request && $request->isSecure()) {
|
||||
$this->storage->setOptions(['cookie_secure' => true]);
|
||||
}
|
||||
|
||||
return $this->storage;
|
||||
}
|
||||
}
|
25
vendor/symfony/http-foundation/Session/Storage/SessionStorageFactoryInterface.php
vendored
Normal file
25
vendor/symfony/http-foundation/Session/Storage/SessionStorageFactoryInterface.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
||||
*/
|
||||
interface SessionStorageFactoryInterface
|
||||
{
|
||||
/**
|
||||
* Creates a new instance of SessionStorageInterface.
|
||||
*/
|
||||
public function createStorage(?Request $request): SessionStorageInterface;
|
||||
}
|
@@ -24,7 +24,7 @@ interface SessionStorageInterface
|
||||
/**
|
||||
* Starts the session.
|
||||
*
|
||||
* @return bool True if started
|
||||
* @return bool
|
||||
*
|
||||
* @throws \RuntimeException if something goes wrong starting the session
|
||||
*/
|
||||
@@ -33,37 +33,33 @@ interface SessionStorageInterface
|
||||
/**
|
||||
* Checks if the session is started.
|
||||
*
|
||||
* @return bool True if started, false otherwise
|
||||
* @return bool
|
||||
*/
|
||||
public function isStarted();
|
||||
|
||||
/**
|
||||
* Returns the session ID.
|
||||
*
|
||||
* @return string The session ID or empty
|
||||
* @return string
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
/**
|
||||
* Sets the session ID.
|
||||
*
|
||||
* @param string $id
|
||||
*/
|
||||
public function setId($id);
|
||||
public function setId(string $id);
|
||||
|
||||
/**
|
||||
* Returns the session name.
|
||||
*
|
||||
* @return mixed The session name
|
||||
* @return string
|
||||
*/
|
||||
public function getName();
|
||||
|
||||
/**
|
||||
* Sets the session name.
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName($name);
|
||||
public function setName(string $name);
|
||||
|
||||
/**
|
||||
* Regenerates id that represents this storage.
|
||||
@@ -90,11 +86,11 @@ interface SessionStorageInterface
|
||||
* to expire with browser session. Time is in seconds, and is
|
||||
* not a Unix timestamp.
|
||||
*
|
||||
* @return bool True if session regenerated, false if error
|
||||
* @return bool
|
||||
*
|
||||
* @throws \RuntimeException If an error occurs while regenerating this storage
|
||||
*/
|
||||
public function regenerate($destroy = false, $lifetime = null);
|
||||
public function regenerate(bool $destroy = false, int $lifetime = null);
|
||||
|
||||
/**
|
||||
* Force the session to be saved and closed.
|
||||
@@ -117,13 +113,11 @@ interface SessionStorageInterface
|
||||
/**
|
||||
* Gets a SessionBagInterface by name.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return SessionBagInterface
|
||||
*
|
||||
* @throws \InvalidArgumentException If the bag does not exist
|
||||
*/
|
||||
public function getBag($name);
|
||||
public function getBag(string $name);
|
||||
|
||||
/**
|
||||
* Registers a SessionBagInterface for use.
|
||||
|
Reference in New Issue
Block a user