summaryrefslogtreecommitdiff
path: root/vendor/symfony/http-foundation/Session
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@webtrees.net>2018-12-01 17:57:53 +0000
committerGreg Roach <fisharebest@webtrees.net>2018-12-01 18:56:03 +0000
commite70f282ef978b175c5529f439f3b572c5b8531a2 (patch)
treecc022e973d89a5507dcbb35561ef93852c551dff /vendor/symfony/http-foundation/Session
parentc16be598f1a8d42127bd64c4878bd92297e18f3b (diff)
downloadwebtrees-e70f282ef978b175c5529f439f3b572c5b8531a2.tar.gz
webtrees-e70f282ef978b175c5529f439f3b572c5b8531a2.tar.bz2
webtrees-e70f282ef978b175c5529f439f3b572c5b8531a2.zip
Update minimum version of PHP to 7.1
Diffstat (limited to 'vendor/symfony/http-foundation/Session')
-rw-r--r--vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php2
-rw-r--r--vendor/symfony/http-foundation/Session/Attribute/NamespacedAttributeBag.php2
-rw-r--r--vendor/symfony/http-foundation/Session/Flash/AutoExpireFlashBag.php2
-rw-r--r--vendor/symfony/http-foundation/Session/Flash/FlashBag.php2
-rw-r--r--vendor/symfony/http-foundation/Session/SessionUtils.php59
-rw-r--r--vendor/symfony/http-foundation/Session/Storage/Handler/AbstractSessionHandler.php48
-rw-r--r--vendor/symfony/http-foundation/Session/Storage/Handler/MemcacheSessionHandler.php118
-rw-r--r--vendor/symfony/http-foundation/Session/Storage/Handler/MigratingSessionHandler.php124
-rw-r--r--vendor/symfony/http-foundation/Session/Storage/Handler/MongoDbSessionHandler.php98
-rw-r--r--vendor/symfony/http-foundation/Session/Storage/Handler/NativeFileSessionHandler.php4
-rw-r--r--vendor/symfony/http-foundation/Session/Storage/Handler/NativeSessionHandler.php24
-rw-r--r--vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php24
-rw-r--r--vendor/symfony/http-foundation/Session/Storage/Handler/RedisSessionHandler.php114
-rw-r--r--vendor/symfony/http-foundation/Session/Storage/Handler/WriteCheckSessionHandler.php92
-rw-r--r--vendor/symfony/http-foundation/Session/Storage/MetadataBag.php2
-rw-r--r--vendor/symfony/http-foundation/Session/Storage/MockArraySessionStorage.php6
-rw-r--r--vendor/symfony/http-foundation/Session/Storage/MockFileSessionStorage.php2
-rw-r--r--vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php41
-rw-r--r--vendor/symfony/http-foundation/Session/Storage/Proxy/NativeProxy.php40
19 files changed, 371 insertions, 433 deletions
diff --git a/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php b/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php
index fc5fb14101..82577b804e 100644
--- a/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php
+++ b/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php
@@ -24,7 +24,7 @@ class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Counta
/**
* @param string $storageKey The key used to store attributes in the session
*/
- public function __construct($storageKey = '_sf2_attributes')
+ public function __construct(string $storageKey = '_sf2_attributes')
{
$this->storageKey = $storageKey;
}
diff --git a/vendor/symfony/http-foundation/Session/Attribute/NamespacedAttributeBag.php b/vendor/symfony/http-foundation/Session/Attribute/NamespacedAttributeBag.php
index 2f1e01a971..50cd740d95 100644
--- a/vendor/symfony/http-foundation/Session/Attribute/NamespacedAttributeBag.php
+++ b/vendor/symfony/http-foundation/Session/Attribute/NamespacedAttributeBag.php
@@ -25,7 +25,7 @@ class NamespacedAttributeBag extends AttributeBag
* @param string $storageKey Session storage key
* @param string $namespaceCharacter Namespace character to use in keys
*/
- public function __construct($storageKey = '_sf2_attributes', $namespaceCharacter = '/')
+ public function __construct(string $storageKey = '_sf2_attributes', string $namespaceCharacter = '/')
{
$this->namespaceCharacter = $namespaceCharacter;
parent::__construct($storageKey);
diff --git a/vendor/symfony/http-foundation/Session/Flash/AutoExpireFlashBag.php b/vendor/symfony/http-foundation/Session/Flash/AutoExpireFlashBag.php
index 77521c2478..ef23457b41 100644
--- a/vendor/symfony/http-foundation/Session/Flash/AutoExpireFlashBag.php
+++ b/vendor/symfony/http-foundation/Session/Flash/AutoExpireFlashBag.php
@@ -25,7 +25,7 @@ class AutoExpireFlashBag implements FlashBagInterface
/**
* @param string $storageKey The key used to store flashes in the session
*/
- public function __construct($storageKey = '_symfony_flashes')
+ public function __construct(string $storageKey = '_symfony_flashes')
{
$this->storageKey = $storageKey;
}
diff --git a/vendor/symfony/http-foundation/Session/Flash/FlashBag.php b/vendor/symfony/http-foundation/Session/Flash/FlashBag.php
index 12fb740c52..44ddb96330 100644
--- a/vendor/symfony/http-foundation/Session/Flash/FlashBag.php
+++ b/vendor/symfony/http-foundation/Session/Flash/FlashBag.php
@@ -25,7 +25,7 @@ class FlashBag implements FlashBagInterface
/**
* @param string $storageKey The key used to store flashes in the session
*/
- public function __construct($storageKey = '_symfony_flashes')
+ public function __construct(string $storageKey = '_symfony_flashes')
{
$this->storageKey = $storageKey;
}
diff --git a/vendor/symfony/http-foundation/Session/SessionUtils.php b/vendor/symfony/http-foundation/Session/SessionUtils.php
new file mode 100644
index 0000000000..91737c39ac
--- /dev/null
+++ b/vendor/symfony/http-foundation/Session/SessionUtils.php
@@ -0,0 +1,59 @@
+<?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;
+
+/**
+ * Session utility functions.
+ *
+ * @author Nicolas Grekas <p@tchwork.com>
+ * @author Rémon van de Kamp <rpkamp@gmail.com>
+ *
+ * @internal
+ */
+final class SessionUtils
+{
+ /**
+ * Finds the session header amongst the headers that are to be sent, removes it, and returns
+ * it so the caller can process it further.
+ */
+ public static function popSessionCookie(string $sessionName, string $sessionId): ?string
+ {
+ $sessionCookie = null;
+ $sessionCookiePrefix = sprintf(' %s=', urlencode($sessionName));
+ $sessionCookieWithId = sprintf('%s%s;', $sessionCookiePrefix, urlencode($sessionId));
+ $otherCookies = array();
+ foreach (headers_list() as $h) {
+ if (0 !== stripos($h, 'Set-Cookie:')) {
+ continue;
+ }
+ if (11 === strpos($h, $sessionCookiePrefix, 11)) {
+ $sessionCookie = $h;
+
+ if (11 !== strpos($h, $sessionCookieWithId, 11)) {
+ $otherCookies[] = $h;
+ }
+ } else {
+ $otherCookies[] = $h;
+ }
+ }
+ if (null === $sessionCookie) {
+ return null;
+ }
+
+ header_remove('Set-Cookie');
+ foreach ($otherCookies as $h) {
+ header($h, false);
+ }
+
+ return $sessionCookie;
+ }
+}
diff --git a/vendor/symfony/http-foundation/Session/Storage/Handler/AbstractSessionHandler.php b/vendor/symfony/http-foundation/Session/Storage/Handler/AbstractSessionHandler.php
index 5b5c1d8170..95f110332a 100644
--- a/vendor/symfony/http-foundation/Session/Storage/Handler/AbstractSessionHandler.php
+++ b/vendor/symfony/http-foundation/Session/Storage/Handler/AbstractSessionHandler.php
@@ -11,6 +11,8 @@
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
+use Symfony\Component\HttpFoundation\Session\SessionUtils;
+
/**
* This abstract session handler provides a generic implementation
* of the PHP 7.0 SessionUpdateTimestampHandlerInterface,
@@ -91,9 +93,6 @@ abstract class AbstractSessionHandler implements \SessionHandlerInterface, \Sess
$data = $this->doRead($sessionId);
$this->newSessionId = '' === $data ? $sessionId : null;
- if (\PHP_VERSION_ID < 70000) {
- $this->prefetchData = $data;
- }
return $data;
}
@@ -103,14 +102,6 @@ abstract class AbstractSessionHandler implements \SessionHandlerInterface, \Sess
*/
public function write($sessionId, $data)
{
- if (\PHP_VERSION_ID < 70000 && $this->prefetchData) {
- $readData = $this->prefetchData;
- $this->prefetchData = null;
-
- if ($readData === $data) {
- return $this->updateTimestamp($sessionId, $data);
- }
- }
if (null === $this->igbinaryEmptyData) {
// see https://github.com/igbinary/igbinary/issues/146
$this->igbinaryEmptyData = \function_exists('igbinary_serialize') ? igbinary_serialize(array()) : '';
@@ -128,38 +119,19 @@ abstract class AbstractSessionHandler implements \SessionHandlerInterface, \Sess
*/
public function destroy($sessionId)
{
- if (\PHP_VERSION_ID < 70000) {
- $this->prefetchData = null;
- }
- if (!headers_sent() && ini_get('session.use_cookies')) {
+ if (!headers_sent() && filter_var(ini_get('session.use_cookies'), FILTER_VALIDATE_BOOLEAN)) {
if (!$this->sessionName) {
throw new \LogicException(sprintf('Session name cannot be empty, did you forget to call "parent::open()" in "%s"?.', \get_class($this)));
}
- $sessionCookie = sprintf(' %s=', urlencode($this->sessionName));
- $sessionCookieWithId = sprintf('%s%s;', $sessionCookie, urlencode($sessionId));
- $sessionCookieFound = false;
- $otherCookies = array();
- foreach (headers_list() as $h) {
- if (0 !== stripos($h, 'Set-Cookie:')) {
- continue;
- }
- if (11 === strpos($h, $sessionCookie, 11)) {
- $sessionCookieFound = true;
-
- if (11 !== strpos($h, $sessionCookieWithId, 11)) {
- $otherCookies[] = $h;
- }
+ $cookie = SessionUtils::popSessionCookie($this->sessionName, $sessionId);
+ if (null === $cookie) {
+ if (\PHP_VERSION_ID < 70300) {
+ setcookie($this->sessionName, '', 0, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), filter_var(ini_get('session.cookie_secure'), FILTER_VALIDATE_BOOLEAN), filter_var(ini_get('session.cookie_httponly'), FILTER_VALIDATE_BOOLEAN));
} else {
- $otherCookies[] = $h;
- }
- }
- if ($sessionCookieFound) {
- header_remove('Set-Cookie');
- foreach ($otherCookies as $h) {
- header($h, false);
+ $params = session_get_cookie_params();
+ unset($params['lifetime']);
+ setcookie($this->sessionName, '', $params);
}
- } else {
- setcookie($this->sessionName, '', 0, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), ini_get('session.cookie_secure'), ini_get('session.cookie_httponly'));
}
}
diff --git a/vendor/symfony/http-foundation/Session/Storage/Handler/MemcacheSessionHandler.php b/vendor/symfony/http-foundation/Session/Storage/Handler/MemcacheSessionHandler.php
deleted file mode 100644
index 1b12c92189..0000000000
--- a/vendor/symfony/http-foundation/Session/Storage/Handler/MemcacheSessionHandler.php
+++ /dev/null
@@ -1,118 +0,0 @@
-<?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;
-
-@trigger_error(sprintf('The class %s is deprecated since Symfony 3.4 and will be removed in 4.0. Use Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler instead.', MemcacheSessionHandler::class), E_USER_DEPRECATED);
-
-/**
- * @author Drak <drak@zikula.org>
- *
- * @deprecated since version 3.4, to be removed in 4.0. Use Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler instead.
- */
-class MemcacheSessionHandler implements \SessionHandlerInterface
-{
- private $memcache;
-
- /**
- * @var int Time to live in seconds
- */
- private $ttl;
-
- /**
- * @var string Key prefix for shared environments
- */
- private $prefix;
-
- /**
- * Constructor.
- *
- * List of available options:
- * * prefix: The prefix to use for the memcache keys in order to avoid collision
- * * expiretime: The time to live in seconds
- *
- * @param \Memcache $memcache A \Memcache instance
- * @param array $options An associative array of Memcache options
- *
- * @throws \InvalidArgumentException When unsupported options are passed
- */
- public function __construct(\Memcache $memcache, array $options = array())
- {
- if ($diff = array_diff(array_keys($options), array('prefix', 'expiretime'))) {
- throw new \InvalidArgumentException(sprintf('The following options are not supported "%s"', implode(', ', $diff)));
- }
-
- $this->memcache = $memcache;
- $this->ttl = isset($options['expiretime']) ? (int) $options['expiretime'] : 86400;
- $this->prefix = isset($options['prefix']) ? $options['prefix'] : 'sf2s';
- }
-
- /**
- * {@inheritdoc}
- */
- public function open($savePath, $sessionName)
- {
- return true;
- }
-
- /**
- * {@inheritdoc}
- */
- public function close()
- {
- return true;
- }
-
- /**
- * {@inheritdoc}
- */
- public function read($sessionId)
- {
- return $this->memcache->get($this->prefix.$sessionId) ?: '';
- }
-
- /**
- * {@inheritdoc}
- */
- public function write($sessionId, $data)
- {
- return $this->memcache->set($this->prefix.$sessionId, $data, 0, time() + $this->ttl);
- }
-
- /**
- * {@inheritdoc}
- */
- public function destroy($sessionId)
- {
- $this->memcache->delete($this->prefix.$sessionId);
-
- return true;
- }
-
- /**
- * {@inheritdoc}
- */
- public function gc($maxlifetime)
- {
- // not required here because memcache will auto expire the records anyhow.
- return true;
- }
-
- /**
- * Return a Memcache instance.
- *
- * @return \Memcache
- */
- protected function getMemcache()
- {
- return $this->memcache;
- }
-}
diff --git a/vendor/symfony/http-foundation/Session/Storage/Handler/MigratingSessionHandler.php b/vendor/symfony/http-foundation/Session/Storage/Handler/MigratingSessionHandler.php
new file mode 100644
index 0000000000..5293d2448a
--- /dev/null
+++ b/vendor/symfony/http-foundation/Session/Storage/Handler/MigratingSessionHandler.php
@@ -0,0 +1,124 @@
+<?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;
+
+/**
+ * Migrating session handler for migrating from one handler to another. It reads
+ * from the current handler and writes both the current and new ones.
+ *
+ * It ignores errors from the new handler.
+ *
+ * @author Ross Motley <ross.motley@amara.com>
+ * @author Oliver Radwell <oliver.radwell@amara.com>
+ */
+class MigratingSessionHandler implements \SessionHandlerInterface, \SessionUpdateTimestampHandlerInterface
+{
+ private $currentHandler;
+ private $writeOnlyHandler;
+
+ public function __construct(\SessionHandlerInterface $currentHandler, \SessionHandlerInterface $writeOnlyHandler)
+ {
+ if (!$currentHandler instanceof \SessionUpdateTimestampHandlerInterface) {
+ $currentHandler = new StrictSessionHandler($currentHandler);
+ }
+ if (!$writeOnlyHandler instanceof \SessionUpdateTimestampHandlerInterface) {
+ $writeOnlyHandler = new StrictSessionHandler($writeOnlyHandler);
+ }
+
+ $this->currentHandler = $currentHandler;
+ $this->writeOnlyHandler = $writeOnlyHandler;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function close()
+ {
+ $result = $this->currentHandler->close();
+ $this->writeOnlyHandler->close();
+
+ return $result;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function destroy($sessionId)
+ {
+ $result = $this->currentHandler->destroy($sessionId);
+ $this->writeOnlyHandler->destroy($sessionId);
+
+ return $result;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function gc($maxlifetime)
+ {
+ $result = $this->currentHandler->gc($maxlifetime);
+ $this->writeOnlyHandler->gc($maxlifetime);
+
+ return $result;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function open($savePath, $sessionName)
+ {
+ $result = $this->currentHandler->open($savePath, $sessionName);
+ $this->writeOnlyHandler->open($savePath, $sessionName);
+
+ return $result;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function read($sessionId)
+ {
+ // No reading from new handler until switch-over
+ return $this->currentHandler->read($sessionId);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function write($sessionId, $sessionData)
+ {
+ $result = $this->currentHandler->write($sessionId, $sessionData);
+ $this->writeOnlyHandler->write($sessionId, $sessionData);
+
+ return $result;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function validateId($sessionId)
+ {
+ // No reading from new handler until switch-over
+ return $this->currentHandler->validateId($sessionId);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function updateTimestamp($sessionId, $sessionData)
+ {
+ $result = $this->currentHandler->updateTimestamp($sessionId, $sessionData);
+ $this->writeOnlyHandler->updateTimestamp($sessionId, $sessionData);
+
+ return $result;
+ }
+}
diff --git a/vendor/symfony/http-foundation/Session/Storage/Handler/MongoDbSessionHandler.php b/vendor/symfony/http-foundation/Session/Storage/Handler/MongoDbSessionHandler.php
index 7d3fa218a2..853b0bc723 100644
--- a/vendor/symfony/http-foundation/Session/Storage/Handler/MongoDbSessionHandler.php
+++ b/vendor/symfony/http-foundation/Session/Storage/Handler/MongoDbSessionHandler.php
@@ -24,7 +24,7 @@ class MongoDbSessionHandler extends AbstractSessionHandler
private $mongo;
/**
- * @var \MongoCollection
+ * @var \MongoDB\Collection
*/
private $collection;
@@ -64,19 +64,10 @@ class MongoDbSessionHandler extends AbstractSessionHandler
* @param \MongoDB\Client $mongo A MongoDB\Client instance
* @param array $options An associative array of field options
*
- * @throws \InvalidArgumentException When MongoClient or Mongo instance not provided
* @throws \InvalidArgumentException When "database" or "collection" not provided
*/
- public function __construct($mongo, array $options)
+ public function __construct(\MongoDB\Client $mongo, array $options)
{
- if ($mongo instanceof \MongoClient || $mongo instanceof \Mongo) {
- @trigger_error(sprintf('Using %s with the legacy mongo extension is deprecated as of 3.4 and will be removed in 4.0. Use it with the mongodb/mongodb package and ext-mongodb instead.', __CLASS__), E_USER_DEPRECATED);
- }
-
- if (!($mongo instanceof \MongoDB\Client || $mongo instanceof \MongoClient || $mongo instanceof \Mongo)) {
- throw new \InvalidArgumentException('MongoClient or Mongo instance required');
- }
-
if (!isset($options['database']) || !isset($options['collection'])) {
throw new \InvalidArgumentException('You must provide the "database" and "collection" option for MongoDBSessionHandler');
}
@@ -104,9 +95,7 @@ class MongoDbSessionHandler extends AbstractSessionHandler
*/
protected function doDestroy($sessionId)
{
- $methodName = $this->mongo instanceof \MongoDB\Client ? 'deleteOne' : 'remove';
-
- $this->getCollection()->$methodName(array(
+ $this->getCollection()->deleteOne(array(
$this->options['id_field'] => $sessionId,
));
@@ -118,10 +107,8 @@ class MongoDbSessionHandler extends AbstractSessionHandler
*/
public function gc($maxlifetime)
{
- $methodName = $this->mongo instanceof \MongoDB\Client ? 'deleteMany' : 'remove';
-
- $this->getCollection()->$methodName(array(
- $this->options['expiry_field'] => array('$lt' => $this->createDateTime()),
+ $this->getCollection()->deleteMany(array(
+ $this->options['expiry_field'] => array('$lt' => new \MongoDB\BSON\UTCDateTime()),
));
return true;
@@ -132,28 +119,18 @@ class MongoDbSessionHandler extends AbstractSessionHandler
*/
protected function doWrite($sessionId, $data)
{
- $expiry = $this->createDateTime(time() + (int) ini_get('session.gc_maxlifetime'));
+ $expiry = new \MongoDB\BSON\UTCDateTime((time() + (int) ini_get('session.gc_maxlifetime')) * 1000);
$fields = array(
- $this->options['time_field'] => $this->createDateTime(),
+ $this->options['time_field'] => new \MongoDB\BSON\UTCDateTime(),
$this->options['expiry_field'] => $expiry,
+ $this->options['data_field'] => new \MongoDB\BSON\Binary($data, \MongoDB\BSON\Binary::TYPE_OLD_BINARY),
);
- $options = array('upsert' => true);
-
- if ($this->mongo instanceof \MongoDB\Client) {
- $fields[$this->options['data_field']] = new \MongoDB\BSON\Binary($data, \MongoDB\BSON\Binary::TYPE_OLD_BINARY);
- } else {
- $fields[$this->options['data_field']] = new \MongoBinData($data, \MongoBinData::BYTE_ARRAY);
- $options['multiple'] = false;
- }
-
- $methodName = $this->mongo instanceof \MongoDB\Client ? 'updateOne' : 'update';
-
- $this->getCollection()->$methodName(
+ $this->getCollection()->updateOne(
array($this->options['id_field'] => $sessionId),
array('$set' => $fields),
- $options
+ array('upsert' => true)
);
return true;
@@ -164,23 +141,14 @@ class MongoDbSessionHandler extends AbstractSessionHandler
*/
public function updateTimestamp($sessionId, $data)
{
- $expiry = $this->createDateTime(time() + (int) ini_get('session.gc_maxlifetime'));
+ $expiry = new \MongoDB\BSON\UTCDateTime((time() + (int) ini_get('session.gc_maxlifetime')) * 1000);
- if ($this->mongo instanceof \MongoDB\Client) {
- $methodName = 'updateOne';
- $options = array();
- } else {
- $methodName = 'update';
- $options = array('multiple' => false);
- }
-
- $this->getCollection()->$methodName(
+ $this->getCollection()->updateOne(
array($this->options['id_field'] => $sessionId),
array('$set' => array(
- $this->options['time_field'] => $this->createDateTime(),
+ $this->options['time_field'] => new \MongoDB\BSON\UTCDateTime(),
$this->options['expiry_field'] => $expiry,
- )),
- $options
+ ))
);
return true;
@@ -193,24 +161,18 @@ class MongoDbSessionHandler extends AbstractSessionHandler
{
$dbData = $this->getCollection()->findOne(array(
$this->options['id_field'] => $sessionId,
- $this->options['expiry_field'] => array('$gte' => $this->createDateTime()),
+ $this->options['expiry_field'] => array('$gte' => new \MongoDB\BSON\UTCDateTime()),
));
if (null === $dbData) {
return '';
}
- if ($dbData[$this->options['data_field']] instanceof \MongoDB\BSON\Binary) {
- return $dbData[$this->options['data_field']]->getData();
- }
-
- return $dbData[$this->options['data_field']]->bin;
+ return $dbData[$this->options['data_field']]->getData();
}
/**
- * Return a "MongoCollection" instance.
- *
- * @return \MongoCollection
+ * @return \MongoDB\Collection
*/
private function getCollection()
{
@@ -222,34 +184,10 @@ class MongoDbSessionHandler extends AbstractSessionHandler
}
/**
- * Return a Mongo instance.
- *
- * @return \Mongo|\MongoClient|\MongoDB\Client
+ * @return \MongoDB\Client
*/
protected function getMongo()
{
return $this->mongo;
}
-
- /**
- * Create a date object using the class appropriate for the current mongo connection.
- *
- * Return an instance of a MongoDate or \MongoDB\BSON\UTCDateTime
- *
- * @param int $seconds An integer representing UTC seconds since Jan 1 1970. Defaults to now.
- *
- * @return \MongoDate|\MongoDB\BSON\UTCDateTime
- */
- private function createDateTime($seconds = null)
- {
- if (null === $seconds) {
- $seconds = time();
- }
-
- if ($this->mongo instanceof \MongoDB\Client) {
- return new \MongoDB\BSON\UTCDateTime($seconds * 1000);
- }
-
- return new \MongoDate($seconds);
- }
}
diff --git a/vendor/symfony/http-foundation/Session/Storage/Handler/NativeFileSessionHandler.php b/vendor/symfony/http-foundation/Session/Storage/Handler/NativeFileSessionHandler.php
index 4e9704bd58..f962965a82 100644
--- a/vendor/symfony/http-foundation/Session/Storage/Handler/NativeFileSessionHandler.php
+++ b/vendor/symfony/http-foundation/Session/Storage/Handler/NativeFileSessionHandler.php
@@ -16,7 +16,7 @@ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
*
* @author Drak <drak@zikula.org>
*/
-class NativeFileSessionHandler extends NativeSessionHandler
+class NativeFileSessionHandler extends \SessionHandler
{
/**
* @param string $savePath Path of directory to save session files
@@ -28,7 +28,7 @@ class NativeFileSessionHandler extends NativeSessionHandler
* @throws \InvalidArgumentException On invalid $savePath
* @throws \RuntimeException When failing to create the save directory
*/
- public function __construct($savePath = null)
+ public function __construct(string $savePath = null)
{
if (null === $savePath) {
$savePath = ini_get('session.save_path');
diff --git a/vendor/symfony/http-foundation/Session/Storage/Handler/NativeSessionHandler.php b/vendor/symfony/http-foundation/Session/Storage/Handler/NativeSessionHandler.php
deleted file mode 100644
index 9be4528aeb..0000000000
--- a/vendor/symfony/http-foundation/Session/Storage/Handler/NativeSessionHandler.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?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;
-
-/**
- * @deprecated since version 3.4, to be removed in 4.0. Use \SessionHandler instead.
- * @see http://php.net/sessionhandler
- */
-class NativeSessionHandler extends \SessionHandler
-{
- public function __construct()
- {
- @trigger_error('The '.__NAMESPACE__.'\NativeSessionHandler class is deprecated since Symfony 3.4 and will be removed in 4.0. Use the \SessionHandler class instead.', E_USER_DEPRECATED);
- }
-}
diff --git a/vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php b/vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php
index c5f0527f9c..1bb647ef42 100644
--- a/vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php
+++ b/vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php
@@ -637,7 +637,7 @@ class PdoSessionHandler extends AbstractSessionHandler
throw new \RuntimeException('Failed to read session: INSERT reported a duplicate id but next SELECT did not return any data.');
}
- if (!ini_get('session.use_strict_mode') && self::LOCK_TRANSACTIONAL === $this->lockMode && 'sqlite' !== $this->driver) {
+ if (!filter_var(ini_get('session.use_strict_mode'), FILTER_VALIDATE_BOOLEAN) && self::LOCK_TRANSACTIONAL === $this->lockMode && 'sqlite' !== $this->driver) {
// In strict mode, session fixation is not possible: new sessions always start with a unique
// random id, so that concurrency is not possible and this code path can be skipped.
// Exclusive-reading of non-existent rows does not block, so we need to do an insert to block
@@ -668,8 +668,6 @@ class PdoSessionHandler extends AbstractSessionHandler
/**
* Executes an application-level lock on the database.
*
- * @param string $sessionId Session ID
- *
* @return \PDOStatement The statement that needs to be executed later to release the lock
*
* @throws \DomainException When an unsupported PDO driver is used
@@ -678,7 +676,7 @@ class PdoSessionHandler extends AbstractSessionHandler
* - for oci using DBMS_LOCK.REQUEST
* - for sqlsrv using sp_getapplock with LockOwner = Session
*/
- private function doAdvisoryLock($sessionId)
+ private function doAdvisoryLock(string $sessionId)
{
switch ($this->driver) {
case 'mysql':
@@ -733,12 +731,8 @@ class PdoSessionHandler extends AbstractSessionHandler
* Encodes the first 4 (when PHP_INT_SIZE == 4) or 8 characters of the string as an integer.
*
* Keep in mind, PHP integers are signed.
- *
- * @param string $string
- *
- * @return int
*/
- private function convertStringToInt($string)
+ private function convertStringToInt(string $string): int
{
if (4 === \PHP_INT_SIZE) {
return (\ord($string[3]) << 24) + (\ord($string[2]) << 16) + (\ord($string[1]) << 8) + \ord($string[0]);
@@ -753,11 +747,9 @@ class PdoSessionHandler extends AbstractSessionHandler
/**
* Return a locking or nonlocking SQL query to read session information.
*
- * @return string The SQL string
- *
* @throws \DomainException When an unsupported PDO driver is used
*/
- private function getSelectSql()
+ private function getSelectSql(): string
{
if (self::LOCK_TRANSACTIONAL === $this->lockMode) {
$this->beginTransaction();
@@ -848,14 +840,8 @@ class PdoSessionHandler extends AbstractSessionHandler
/**
* Returns a merge/upsert (i.e. insert or update) statement when supported by the database for writing session data.
- *
- * @param string $sessionId Session ID
- * @param string $data Encoded session data
- * @param int $maxlifetime session.gc_maxlifetime
- *
- * @return \PDOStatement|null The merge statement or null when not supported
*/
- private function getMergeStatement($sessionId, $data, $maxlifetime)
+ private function getMergeStatement(string $sessionId, string $data, int $maxlifetime): ?\PDOStatement
{
switch (true) {
case 'mysql' === $this->driver:
diff --git a/vendor/symfony/http-foundation/Session/Storage/Handler/RedisSessionHandler.php b/vendor/symfony/http-foundation/Session/Storage/Handler/RedisSessionHandler.php
new file mode 100644
index 0000000000..9c08ddcc01
--- /dev/null
+++ b/vendor/symfony/http-foundation/Session/Storage/Handler/RedisSessionHandler.php
@@ -0,0 +1,114 @@
+<?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 Predis\Response\ErrorInterface;
+use Symfony\Component\Cache\Traits\RedisClusterProxy;
+use Symfony\Component\Cache\Traits\RedisProxy;
+
+/**
+ * Redis based session storage handler based on the Redis class
+ * provided by the PHP redis extension.
+ *
+ * @author Dalibor Karlović <dalibor@flexolabs.io>
+ */
+class RedisSessionHandler extends AbstractSessionHandler
+{
+ private $redis;
+
+ /**
+ * @var string Key prefix for shared environments
+ */
+ private $prefix;
+
+ /**
+ * List of available options:
+ * * prefix: The prefix to use for the keys in order to avoid collision on the Redis server.
+ *
+ * @param \Redis|\RedisArray|\RedisCluster|\Predis\Client|RedisProxy $redis
+ * @param array $options An associative array of options
+ *
+ * @throws \InvalidArgumentException When unsupported client or options are passed
+ */
+ public function __construct($redis, array $options = array())
+ {
+ if (
+ !$redis instanceof \Redis &&
+ !$redis instanceof \RedisArray &&
+ !$redis instanceof \RedisCluster &&
+ !$redis instanceof \Predis\Client &&
+ !$redis instanceof RedisProxy &&
+ !$redis instanceof RedisClusterProxy
+ ) {
+ throw new \InvalidArgumentException(sprintf('%s() expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\Client, %s given', __METHOD__, \is_object($redis) ? \get_class($redis) : \gettype($redis)));
+ }
+
+ if ($diff = array_diff(array_keys($options), array('prefix'))) {
+ throw new \InvalidArgumentException(sprintf('The following options are not supported "%s"', implode(', ', $diff)));
+ }
+
+ $this->redis = $redis;
+ $this->prefix = $options['prefix'] ?? 'sf_s';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function doRead($sessionId): string
+ {
+ return $this->redis->get($this->prefix.$sessionId) ?: '';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function doWrite($sessionId, $data): bool
+ {
+ $result = $this->redis->setEx($this->prefix.$sessionId, (int) ini_get('session.gc_maxlifetime'), $data);
+
+ return $result && !$result instanceof ErrorInterface;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function doDestroy($sessionId): bool
+ {
+ $this->redis->del($this->prefix.$sessionId);
+
+ return true;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function close(): bool
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function gc($maxlifetime): bool
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function updateTimestamp($sessionId, $data)
+ {
+ return (bool) $this->redis->expire($this->prefix.$sessionId, (int) ini_get('session.gc_maxlifetime'));
+ }
+}
diff --git a/vendor/symfony/http-foundation/Session/Storage/Handler/WriteCheckSessionHandler.php b/vendor/symfony/http-foundation/Session/Storage/Handler/WriteCheckSessionHandler.php
deleted file mode 100644
index 127e47f210..0000000000
--- a/vendor/symfony/http-foundation/Session/Storage/Handler/WriteCheckSessionHandler.php
+++ /dev/null
@@ -1,92 +0,0 @@
-<?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;
-
-/**
- * Wraps another SessionHandlerInterface to only write the session when it has been modified.
- *
- * @author Adrien Brault <adrien.brault@gmail.com>
- *
- * @deprecated since version 3.4, to be removed in 4.0. Implement `SessionUpdateTimestampHandlerInterface` or extend `AbstractSessionHandler` instead.
- */
-class WriteCheckSessionHandler implements \SessionHandlerInterface
-{
- private $wrappedSessionHandler;
-
- /**
- * @var array sessionId => session
- */
- private $readSessions;
-
- public function __construct(\SessionHandlerInterface $wrappedSessionHandler)
- {
- @trigger_error(sprintf('The %s class is deprecated since Symfony 3.4 and will be removed in 4.0. Implement `SessionUpdateTimestampHandlerInterface` or extend `AbstractSessionHandler` instead.', self::class), E_USER_DEPRECATED);
-
- $this->wrappedSessionHandler = $wrappedSessionHandler;
- }
-
- /**
- * {@inheritdoc}
- */
- public function close()
- {
- return $this->wrappedSessionHandler->close();
- }
-
- /**
- * {@inheritdoc}
- */
- public function destroy($sessionId)
- {
- return $this->wrappedSessionHandler->destroy($sessionId);
- }
-
- /**
- * {@inheritdoc}
- */
- public function gc($maxlifetime)
- {
- return $this->wrappedSessionHandler->gc($maxlifetime);
- }
-
- /**
- * {@inheritdoc}
- */
- public function open($savePath, $sessionName)
- {
- return $this->wrappedSessionHandler->open($savePath, $sessionName);
- }
-
- /**
- * {@inheritdoc}
- */
- public function read($sessionId)
- {
- $session = $this->wrappedSessionHandler->read($sessionId);
-
- $this->readSessions[$sessionId] = $session;
-
- return $session;
- }
-
- /**
- * {@inheritdoc}
- */
- public function write($sessionId, $data)
- {
- if (isset($this->readSessions[$sessionId]) && $data === $this->readSessions[$sessionId]) {
- return true;
- }
-
- return $this->wrappedSessionHandler->write($sessionId, $data);
- }
-}
diff --git a/vendor/symfony/http-foundation/Session/Storage/MetadataBag.php b/vendor/symfony/http-foundation/Session/Storage/MetadataBag.php
index 6f59af4869..ea0d5ecb51 100644
--- a/vendor/symfony/http-foundation/Session/Storage/MetadataBag.php
+++ b/vendor/symfony/http-foundation/Session/Storage/MetadataBag.php
@@ -57,7 +57,7 @@ class MetadataBag implements SessionBagInterface
* @param string $storageKey The key used to store bag in the session
* @param int $updateThreshold The time to wait between two UPDATED updates
*/
- public function __construct($storageKey = '_sf2_meta', $updateThreshold = 0)
+ public function __construct(string $storageKey = '_sf2_meta', int $updateThreshold = 0)
{
$this->storageKey = $storageKey;
$this->updateThreshold = $updateThreshold;
diff --git a/vendor/symfony/http-foundation/Session/Storage/MockArraySessionStorage.php b/vendor/symfony/http-foundation/Session/Storage/MockArraySessionStorage.php
index 027f4efffc..47cac39854 100644
--- a/vendor/symfony/http-foundation/Session/Storage/MockArraySessionStorage.php
+++ b/vendor/symfony/http-foundation/Session/Storage/MockArraySessionStorage.php
@@ -62,11 +62,7 @@ class MockArraySessionStorage implements SessionStorageInterface
*/
protected $bags = array();
- /**
- * @param string $name Session name
- * @param MetadataBag $metaBag MetadataBag instance
- */
- public function __construct($name = 'MOCKSESSID', MetadataBag $metaBag = null)
+ public function __construct(string $name = 'MOCKSESSID', MetadataBag $metaBag = null)
{
$this->name = $name;
$this->setMetadataBag($metaBag);
diff --git a/vendor/symfony/http-foundation/Session/Storage/MockFileSessionStorage.php b/vendor/symfony/http-foundation/Session/Storage/MockFileSessionStorage.php
index 14f427007b..732f92abf9 100644
--- a/vendor/symfony/http-foundation/Session/Storage/MockFileSessionStorage.php
+++ b/vendor/symfony/http-foundation/Session/Storage/MockFileSessionStorage.php
@@ -31,7 +31,7 @@ class MockFileSessionStorage extends MockArraySessionStorage
* @param string $name Session name
* @param MetadataBag $metaBag MetadataBag instance
*/
- public function __construct($savePath = null, $name = 'MOCKSESSID', MetadataBag $metaBag = null)
+ public function __construct(string $savePath = null, string $name = 'MOCKSESSID', MetadataBag $metaBag = null)
{
if (null === $savePath) {
$savePath = sys_get_temp_dir();
diff --git a/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php b/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php
index 1ec5c7ff4e..156a0d4555 100644
--- a/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php
+++ b/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\HttpFoundation\Session\Storage;
use Symfony\Component\HttpFoundation\Session\SessionBagInterface;
+use Symfony\Component\HttpFoundation\Session\SessionUtils;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\StrictSessionHandler;
use Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy;
use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy;
@@ -49,6 +50,11 @@ class NativeSessionStorage implements SessionStorageInterface
protected $metadataBag;
/**
+ * @var string|null
+ */
+ private $emulateSameSite;
+
+ /**
* Depending on how you want the storage driver to behave you probably
* want to override this constructor entirely.
*
@@ -67,13 +73,10 @@ class NativeSessionStorage implements SessionStorageInterface
* cookie_lifetime, "0"
* cookie_path, "/"
* cookie_secure, ""
- * entropy_file, ""
- * entropy_length, "0"
+ * cookie_samesite, null
* gc_divisor, "100"
* gc_maxlifetime, "1440"
* gc_probability, "1"
- * hash_bits_per_character, "4"
- * hash_function, "0"
* lazy_write, "1"
* name, "PHPSESSID"
* referer_check, ""
@@ -105,6 +108,7 @@ class NativeSessionStorage implements SessionStorageInterface
'cache_expire' => 0,
'use_cookies' => 1,
'lazy_write' => 1,
+ 'use_strict_mode' => 1,
);
session_register_shutdown();
@@ -137,7 +141,7 @@ class NativeSessionStorage implements SessionStorageInterface
throw new \RuntimeException('Failed to start the session: already started by PHP.');
}
- if (ini_get('session.use_cookies') && headers_sent($file, $line)) {
+ if (filter_var(ini_get('session.use_cookies'), FILTER_VALIDATE_BOOLEAN) && headers_sent($file, $line)) {
throw new \RuntimeException(sprintf('Failed to start the session because headers have already been sent by "%s" at line %d.', $file, $line));
}
@@ -146,6 +150,13 @@ class NativeSessionStorage implements SessionStorageInterface
throw new \RuntimeException('Failed to start the session');
}
+ if (null !== $this->emulateSameSite) {
+ $originalCookie = SessionUtils::popSessionCookie(session_name(), session_id());
+ if (null !== $originalCookie) {
+ header(sprintf('%s; SameSite=%s', $originalCookie, $this->emulateSameSite));
+ }
+ }
+
$this->loadSession();
return true;
@@ -211,6 +222,13 @@ class NativeSessionStorage implements SessionStorageInterface
// @see https://bugs.php.net/bug.php?id=70013
$this->loadSession();
+ if (null !== $this->emulateSameSite) {
+ $originalCookie = SessionUtils::popSessionCookie(session_name(), session_id());
+ if (null !== $originalCookie) {
+ header(sprintf('%s; SameSite=%s', $originalCookie, $this->emulateSameSite));
+ }
+ }
+
return $isRegenerated;
}
@@ -343,10 +361,9 @@ class NativeSessionStorage implements SessionStorageInterface
$validOptions = array_flip(array(
'cache_expire', 'cache_limiter', 'cookie_domain', 'cookie_httponly',
- 'cookie_lifetime', 'cookie_path', 'cookie_secure',
- 'entropy_file', 'entropy_length', 'gc_divisor',
- 'gc_maxlifetime', 'gc_probability', 'hash_bits_per_character',
- 'hash_function', 'lazy_write', 'name', 'referer_check',
+ 'cookie_lifetime', 'cookie_path', 'cookie_secure', 'cookie_samesite',
+ 'gc_divisor', 'gc_maxlifetime', 'gc_probability',
+ 'lazy_write', 'name', 'referer_check',
'serialize_handler', 'use_strict_mode', 'use_cookies',
'use_only_cookies', 'use_trans_sid', 'upload_progress.enabled',
'upload_progress.cleanup', 'upload_progress.prefix', 'upload_progress.name',
@@ -356,6 +373,12 @@ class NativeSessionStorage implements SessionStorageInterface
foreach ($options as $key => $value) {
if (isset($validOptions[$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.
+ $this->emulateSameSite = $value;
+ continue;
+ }
ini_set('url_rewriter.tags' !== $key ? 'session.'.$key : $key, $value);
}
}
diff --git a/vendor/symfony/http-foundation/Session/Storage/Proxy/NativeProxy.php b/vendor/symfony/http-foundation/Session/Storage/Proxy/NativeProxy.php
deleted file mode 100644
index 082eed143e..0000000000
--- a/vendor/symfony/http-foundation/Session/Storage/Proxy/NativeProxy.php
+++ /dev/null
@@ -1,40 +0,0 @@
-<?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\Proxy;
-
-@trigger_error('The '.__NAMESPACE__.'\NativeProxy class is deprecated since Symfony 3.4 and will be removed in 4.0. Use your session handler implementation directly.', E_USER_DEPRECATED);
-
-/**
- * This proxy is built-in session handlers in PHP 5.3.x.
- *
- * @deprecated since version 3.4, to be removed in 4.0. Use your session handler implementation directly.
- *
- * @author Drak <drak@zikula.org>
- */
-class NativeProxy extends AbstractProxy
-{
- public function __construct()
- {
- // this makes an educated guess as to what the handler is since it should already be set.
- $this->saveHandlerName = ini_get('session.save_handler');
- }
-
- /**
- * Returns true if this handler wraps an internal PHP session save handler using \SessionHandler.
- *
- * @return bool False
- */
- public function isWrapper()
- {
- return false;
- }
-}