summaryrefslogtreecommitdiff
path: root/vendor/symfony
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony')
-rw-r--r--vendor/symfony/debug/Debug.php5
-rw-r--r--vendor/symfony/debug/Exception/ClassNotFoundException.php3
-rw-r--r--vendor/symfony/debug/Exception/FatalErrorException.php4
-rw-r--r--vendor/symfony/debug/Exception/UndefinedFunctionException.php3
-rw-r--r--vendor/symfony/debug/Exception/UndefinedMethodException.php3
-rw-r--r--vendor/symfony/http-foundation/ResponseHeaderBag.php2
-rw-r--r--vendor/symfony/http-foundation/Session/Session.php19
-rw-r--r--vendor/symfony/http-foundation/Session/SessionBagProxy.php14
-rw-r--r--vendor/symfony/http-foundation/Tests/Fixtures/response-functional/common.inc4
-rw-r--r--vendor/symfony/http-foundation/Tests/JsonResponseTest.php9
-rw-r--r--vendor/symfony/http-foundation/Tests/RequestTest.php1
-rw-r--r--vendor/symfony/http-kernel/DataCollector/DumpDataCollector.php2
-rw-r--r--vendor/symfony/http-kernel/EventListener/AbstractSessionListener.php17
-rw-r--r--vendor/symfony/http-kernel/EventListener/ExceptionListener.php16
-rw-r--r--vendor/symfony/http-kernel/Fragment/InlineFragmentRenderer.php4
-rw-r--r--vendor/symfony/http-kernel/HttpCache/HttpCache.php6
-rw-r--r--vendor/symfony/http-kernel/Kernel.php20
-rw-r--r--vendor/symfony/http-kernel/Tests/EventListener/ExceptionListenerTest.php17
-rw-r--r--vendor/symfony/http-kernel/Tests/EventListener/SessionListenerTest.php38
-rw-r--r--vendor/symfony/http-kernel/Tests/EventListener/ValidateRequestListenerTest.php5
-rw-r--r--vendor/symfony/http-kernel/Tests/Fragment/InlineFragmentRendererTest.php25
-rw-r--r--vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTest.php40
-rw-r--r--vendor/symfony/http-kernel/Tests/HttpKernelTest.php2
-rw-r--r--vendor/symfony/http-kernel/Tests/KernelTest.php19
-rw-r--r--vendor/symfony/http-kernel/composer.json2
25 files changed, 210 insertions, 70 deletions
diff --git a/vendor/symfony/debug/Debug.php b/vendor/symfony/debug/Debug.php
index aaa54118e0..8a2b6c8fe7 100644
--- a/vendor/symfony/debug/Debug.php
+++ b/vendor/symfony/debug/Debug.php
@@ -23,10 +23,7 @@ class Debug
/**
* Enables the debug tools.
*
- * This method registers an error handler and an exception handler.
- *
- * If the Symfony ClassLoader component is available, a special
- * class loader is also registered.
+ * This method registers an error handler, an exception handler and a special class loader.
*
* @param int $errorReportingLevel The level of error reporting you want
* @param bool $displayErrors Whether to display errors (for development) or just log them (for production)
diff --git a/vendor/symfony/debug/Exception/ClassNotFoundException.php b/vendor/symfony/debug/Exception/ClassNotFoundException.php
index b91bf46631..de5c456443 100644
--- a/vendor/symfony/debug/Exception/ClassNotFoundException.php
+++ b/vendor/symfony/debug/Exception/ClassNotFoundException.php
@@ -26,6 +26,9 @@ class ClassNotFoundException extends FatalErrorException
$previous->getSeverity(),
$previous->getFile(),
$previous->getLine(),
+ null,
+ true,
+ null,
$previous->getPrevious()
);
$this->setTrace($previous->getTrace());
diff --git a/vendor/symfony/debug/Exception/FatalErrorException.php b/vendor/symfony/debug/Exception/FatalErrorException.php
index f24a54e77a..6ddfc4c200 100644
--- a/vendor/symfony/debug/Exception/FatalErrorException.php
+++ b/vendor/symfony/debug/Exception/FatalErrorException.php
@@ -18,9 +18,9 @@ namespace Symfony\Component\Debug\Exception;
*/
class FatalErrorException extends \ErrorException
{
- public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true, array $trace = null)
+ public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true, array $trace = null, $previous = null)
{
- parent::__construct($message, $code, $severity, $filename, $lineno);
+ parent::__construct($message, $code, $severity, $filename, $lineno, $previous);
if (null !== $trace) {
if (!$traceArgs) {
diff --git a/vendor/symfony/debug/Exception/UndefinedFunctionException.php b/vendor/symfony/debug/Exception/UndefinedFunctionException.php
index a66ae2a387..8f5f454e55 100644
--- a/vendor/symfony/debug/Exception/UndefinedFunctionException.php
+++ b/vendor/symfony/debug/Exception/UndefinedFunctionException.php
@@ -26,6 +26,9 @@ class UndefinedFunctionException extends FatalErrorException
$previous->getSeverity(),
$previous->getFile(),
$previous->getLine(),
+ null,
+ true,
+ null,
$previous->getPrevious()
);
$this->setTrace($previous->getTrace());
diff --git a/vendor/symfony/debug/Exception/UndefinedMethodException.php b/vendor/symfony/debug/Exception/UndefinedMethodException.php
index 350dc3187f..f7e340baf4 100644
--- a/vendor/symfony/debug/Exception/UndefinedMethodException.php
+++ b/vendor/symfony/debug/Exception/UndefinedMethodException.php
@@ -26,6 +26,9 @@ class UndefinedMethodException extends FatalErrorException
$previous->getSeverity(),
$previous->getFile(),
$previous->getLine(),
+ null,
+ true,
+ null,
$previous->getPrevious()
);
$this->setTrace($previous->getTrace());
diff --git a/vendor/symfony/http-foundation/ResponseHeaderBag.php b/vendor/symfony/http-foundation/ResponseHeaderBag.php
index 11a859326b..e8a05ee68f 100644
--- a/vendor/symfony/http-foundation/ResponseHeaderBag.php
+++ b/vendor/symfony/http-foundation/ResponseHeaderBag.php
@@ -210,7 +210,7 @@ class ResponseHeaderBag extends HeaderBag
*
* @param string $format
*
- * @return array
+ * @return Cookie[]
*
* @throws \InvalidArgumentException When the $format is invalid
*/
diff --git a/vendor/symfony/http-foundation/Session/Session.php b/vendor/symfony/http-foundation/Session/Session.php
index a46cffbb8d..f0379c1697 100644
--- a/vendor/symfony/http-foundation/Session/Session.php
+++ b/vendor/symfony/http-foundation/Session/Session.php
@@ -29,7 +29,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
private $flashName;
private $attributeName;
private $data = array();
- private $hasBeenStarted;
+ private $usageIndex = 0;
/**
* @param SessionStorageInterface $storage A SessionStorageInterface instance
@@ -54,6 +54,8 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
*/
public function start()
{
+ ++$this->usageIndex;
+
return $this->storage->start();
}
@@ -142,13 +144,13 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
}
/**
- * @return bool
+ * @return int
*
* @internal
*/
- public function hasBeenStarted()
+ public function getUsageIndex()
{
- return $this->hasBeenStarted;
+ return $this->usageIndex;
}
/**
@@ -158,6 +160,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
*/
public function isEmpty()
{
+ ++$this->usageIndex;
foreach ($this->data as &$data) {
if (!empty($data)) {
return false;
@@ -182,6 +185,8 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
*/
public function migrate($destroy = false, $lifetime = null)
{
+ ++$this->usageIndex;
+
return $this->storage->regenerate($destroy, $lifetime);
}
@@ -190,6 +195,8 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
*/
public function save()
{
+ ++$this->usageIndex;
+
$this->storage->save();
}
@@ -230,6 +237,8 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
*/
public function getMetadataBag()
{
+ ++$this->usageIndex;
+
return $this->storage->getMetadataBag();
}
@@ -238,7 +247,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
*/
public function registerBag(SessionBagInterface $bag)
{
- $this->storage->registerBag(new SessionBagProxy($bag, $this->data, $this->hasBeenStarted));
+ $this->storage->registerBag(new SessionBagProxy($bag, $this->data, $this->usageIndex));
}
/**
diff --git a/vendor/symfony/http-foundation/Session/SessionBagProxy.php b/vendor/symfony/http-foundation/Session/SessionBagProxy.php
index 307836d5f9..88005ee092 100644
--- a/vendor/symfony/http-foundation/Session/SessionBagProxy.php
+++ b/vendor/symfony/http-foundation/Session/SessionBagProxy.php
@@ -20,13 +20,13 @@ final class SessionBagProxy implements SessionBagInterface
{
private $bag;
private $data;
- private $hasBeenStarted;
+ private $usageIndex;
- public function __construct(SessionBagInterface $bag, array &$data, &$hasBeenStarted)
+ public function __construct(SessionBagInterface $bag, array &$data, &$usageIndex)
{
$this->bag = $bag;
$this->data = &$data;
- $this->hasBeenStarted = &$hasBeenStarted;
+ $this->usageIndex = &$usageIndex;
}
/**
@@ -34,6 +34,8 @@ final class SessionBagProxy implements SessionBagInterface
*/
public function getBag()
{
+ ++$this->usageIndex;
+
return $this->bag;
}
@@ -42,6 +44,8 @@ final class SessionBagProxy implements SessionBagInterface
*/
public function isEmpty()
{
+ ++$this->usageIndex;
+
return empty($this->data[$this->bag->getStorageKey()]);
}
@@ -58,7 +62,7 @@ final class SessionBagProxy implements SessionBagInterface
*/
public function initialize(array &$array)
{
- $this->hasBeenStarted = true;
+ ++$this->usageIndex;
$this->data[$this->bag->getStorageKey()] = &$array;
$this->bag->initialize($array);
@@ -77,6 +81,8 @@ final class SessionBagProxy implements SessionBagInterface
*/
public function clear()
{
+ ++$this->usageIndex;
+
return $this->bag->clear();
}
}
diff --git a/vendor/symfony/http-foundation/Tests/Fixtures/response-functional/common.inc b/vendor/symfony/http-foundation/Tests/Fixtures/response-functional/common.inc
index ba101d3578..f9c40a9a3c 100644
--- a/vendor/symfony/http-foundation/Tests/Fixtures/response-functional/common.inc
+++ b/vendor/symfony/http-foundation/Tests/Fixtures/response-functional/common.inc
@@ -22,6 +22,10 @@ error_reporting(-1);
ini_set('html_errors', 0);
ini_set('display_errors', 1);
+if (ini_get('xdebug.default_enable')) {
+ xdebug_disable();
+}
+
header_remove('X-Powered-By');
header('Content-Type: text/plain; charset=utf-8');
diff --git a/vendor/symfony/http-foundation/Tests/JsonResponseTest.php b/vendor/symfony/http-foundation/Tests/JsonResponseTest.php
index 201839f89c..bd94a24505 100644
--- a/vendor/symfony/http-foundation/Tests/JsonResponseTest.php
+++ b/vendor/symfony/http-foundation/Tests/JsonResponseTest.php
@@ -16,6 +16,15 @@ use Symfony\Component\HttpFoundation\JsonResponse;
class JsonResponseTest extends TestCase
{
+ protected function setUp()
+ {
+ parent::setUp();
+
+ if (!defined('HHVM_VERSION')) {
+ $this->iniSet('serialize_precision', 14);
+ }
+ }
+
public function testConstructorEmptyCreatesJsonObject()
{
$response = new JsonResponse();
diff --git a/vendor/symfony/http-foundation/Tests/RequestTest.php b/vendor/symfony/http-foundation/Tests/RequestTest.php
index 4266197ab2..9d4181fbc7 100644
--- a/vendor/symfony/http-foundation/Tests/RequestTest.php
+++ b/vendor/symfony/http-foundation/Tests/RequestTest.php
@@ -21,7 +21,6 @@ class RequestTest extends TestCase
{
protected function tearDown()
{
- // reset
Request::setTrustedProxies(array(), -1);
Request::setTrustedHosts(array());
}
diff --git a/vendor/symfony/http-kernel/DataCollector/DumpDataCollector.php b/vendor/symfony/http-kernel/DataCollector/DumpDataCollector.php
index 27a9a82524..be06a61c40 100644
--- a/vendor/symfony/http-kernel/DataCollector/DumpDataCollector.php
+++ b/vendor/symfony/http-kernel/DataCollector/DumpDataCollector.php
@@ -171,7 +171,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
}
$this->data = array();
$this->dataCount = 0;
- $this->isCollected = false;
+ $this->isCollected = true;
$this->clonesCount = 0;
$this->clonesIndex = 0;
}
diff --git a/vendor/symfony/http-kernel/EventListener/AbstractSessionListener.php b/vendor/symfony/http-kernel/EventListener/AbstractSessionListener.php
index dff29ee80b..a54ca62d87 100644
--- a/vendor/symfony/http-kernel/EventListener/AbstractSessionListener.php
+++ b/vendor/symfony/http-kernel/EventListener/AbstractSessionListener.php
@@ -14,6 +14,7 @@ namespace Symfony\Component\HttpKernel\EventListener;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
+use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -25,6 +26,8 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
*/
abstract class AbstractSessionListener implements EventSubscriberInterface
{
+ private $sessionUsageStack = array();
+
public function onKernelRequest(GetResponseEvent $event)
{
if (!$event->isMasterRequest()) {
@@ -33,6 +36,7 @@ abstract class AbstractSessionListener implements EventSubscriberInterface
$request = $event->getRequest();
$session = $this->getSession();
+ $this->sessionUsageStack[] = $session instanceof Session ? $session->getUsageIndex() : null;
if (null === $session || $request->hasSession()) {
return;
}
@@ -50,7 +54,7 @@ abstract class AbstractSessionListener implements EventSubscriberInterface
return;
}
- if ($session->isStarted() || ($session instanceof Session && $session->hasBeenStarted())) {
+ if ($session instanceof Session ? $session->getUsageIndex() !== end($this->sessionUsageStack) : $session->isStarted()) {
$event->getResponse()
->setPrivate()
->setMaxAge(0)
@@ -58,12 +62,23 @@ abstract class AbstractSessionListener implements EventSubscriberInterface
}
}
+ /**
+ * @internal
+ */
+ public function onFinishRequest(FinishRequestEvent $event)
+ {
+ if ($event->isMasterRequest()) {
+ array_pop($this->sessionUsageStack);
+ }
+ }
+
public static function getSubscribedEvents()
{
return array(
KernelEvents::REQUEST => array('onKernelRequest', 128),
// low priority to come after regular response listeners, same as SaveSessionListener
KernelEvents::RESPONSE => array('onKernelResponse', -1000),
+ KernelEvents::FINISH_REQUEST => array('onFinishRequest'),
);
}
diff --git a/vendor/symfony/http-kernel/EventListener/ExceptionListener.php b/vendor/symfony/http-kernel/EventListener/ExceptionListener.php
index 3dfa4cd8ea..983f1c2b8f 100644
--- a/vendor/symfony/http-kernel/EventListener/ExceptionListener.php
+++ b/vendor/symfony/http-kernel/EventListener/ExceptionListener.php
@@ -12,11 +12,9 @@
namespace Symfony\Component\HttpKernel\EventListener;
use Psr\Log\LoggerInterface;
-use Symfony\Component\Debug\ExceptionHandler;
use Symfony\Component\Debug\Exception\FlattenException;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
@@ -35,14 +33,12 @@ class ExceptionListener implements EventSubscriberInterface
protected $controller;
protected $logger;
protected $debug;
- private $charset;
- public function __construct($controller, LoggerInterface $logger = null, $debug = false, $charset = null)
+ public function __construct($controller, LoggerInterface $logger = null, $debug = false)
{
$this->controller = $controller;
$this->logger = $logger;
$this->debug = $debug;
- $this->charset = $charset;
}
public function onKernelException(GetResponseForExceptionEvent $event)
@@ -68,7 +64,7 @@ class ExceptionListener implements EventSubscriberInterface
}
}
- $prev = new \ReflectionProperty('Exception', 'previous');
+ $prev = new \ReflectionProperty($wrapper instanceof \Exception ? \Exception::class : \Error::class, 'previous');
$prev->setAccessible(true);
$prev->setValue($wrapper, $exception);
@@ -121,12 +117,8 @@ class ExceptionListener implements EventSubscriberInterface
protected function duplicateRequest(\Exception $exception, Request $request)
{
$attributes = array(
- 'exception' => $exception = FlattenException::create($exception),
- '_controller' => $this->controller ?: function () use ($exception) {
- $handler = new ExceptionHandler($this->debug, $this->charset);
-
- return new Response($handler->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders());
- },
+ '_controller' => $this->controller,
+ 'exception' => FlattenException::create($exception),
'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : null,
);
$request = $request->duplicate(null, null, $attributes);
diff --git a/vendor/symfony/http-kernel/Fragment/InlineFragmentRenderer.php b/vendor/symfony/http-kernel/Fragment/InlineFragmentRenderer.php
index 3f3a51a59e..da64281907 100644
--- a/vendor/symfony/http-kernel/Fragment/InlineFragmentRenderer.php
+++ b/vendor/symfony/http-kernel/Fragment/InlineFragmentRenderer.php
@@ -126,7 +126,9 @@ class InlineFragmentRenderer extends RoutableFragmentRenderer
// Do nothing
}
- $server['REMOTE_ADDR'] = '127.0.0.1';
+ $trustedProxies = Request::getTrustedProxies();
+ $server['REMOTE_ADDR'] = $trustedProxies ? reset($trustedProxies) : '127.0.0.1';
+
unset($server['HTTP_IF_MODIFIED_SINCE']);
unset($server['HTTP_IF_NONE_MATCH']);
diff --git a/vendor/symfony/http-kernel/HttpCache/HttpCache.php b/vendor/symfony/http-kernel/HttpCache/HttpCache.php
index 7c5a44f05b..8cc4b2108c 100644
--- a/vendor/symfony/http-kernel/HttpCache/HttpCache.php
+++ b/vendor/symfony/http-kernel/HttpCache/HttpCache.php
@@ -165,7 +165,11 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
// FIXME: catch exceptions and implement a 500 error page here? -> in Varnish, there is a built-in error page mechanism
if (HttpKernelInterface::MASTER_REQUEST === $type) {
$this->traces = array();
- $this->request = $request;
+ // Keep a clone of the original request for surrogates so they can access it.
+ // We must clone here to get a separate instance because the application will modify the request during
+ // the application flow (we know it always does because we do ourselves by setting REMOTE_ADDR to 127.0.0.1
+ // and adding the X-Forwarded-For header, see HttpCache::forward()).
+ $this->request = clone $request;
if (null !== $this->surrogate) {
$this->surrogateCacheStrategy = $this->surrogate->createCacheStrategy();
}
diff --git a/vendor/symfony/http-kernel/Kernel.php b/vendor/symfony/http-kernel/Kernel.php
index ca0f0b95c7..3c740e45ef 100644
--- a/vendor/symfony/http-kernel/Kernel.php
+++ b/vendor/symfony/http-kernel/Kernel.php
@@ -67,11 +67,11 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
private $requestStackSize = 0;
private $resetServices = false;
- const VERSION = '3.4.11';
- const VERSION_ID = 30411;
+ const VERSION = '3.4.12';
+ const VERSION_ID = 30412;
const MAJOR_VERSION = 3;
const MINOR_VERSION = 4;
- const RELEASE_VERSION = 11;
+ const RELEASE_VERSION = 12;
const EXTRA_VERSION = '';
const END_OF_MAINTENANCE = '11/2020';
@@ -87,18 +87,10 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
$this->debug = (bool) $debug;
$this->rootDir = $this->getRootDir();
$this->name = $this->getName();
-
- if ($this->debug) {
- $this->startTime = microtime(true);
- }
}
public function __clone()
{
- if ($this->debug) {
- $this->startTime = microtime(true);
- }
-
$this->booted = false;
$this->container = null;
$this->requestStackSize = 0;
@@ -116,10 +108,16 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
$this->container->get('services_resetter')->reset();
}
$this->resetServices = false;
+ if ($this->debug) {
+ $this->startTime = microtime(true);
+ }
}
return;
}
+ if ($this->debug) {
+ $this->startTime = microtime(true);
+ }
if ($this->debug && !isset($_ENV['SHELL_VERBOSITY']) && !isset($_SERVER['SHELL_VERBOSITY'])) {
putenv('SHELL_VERBOSITY=3');
$_ENV['SHELL_VERBOSITY'] = 3;
diff --git a/vendor/symfony/http-kernel/Tests/EventListener/ExceptionListenerTest.php b/vendor/symfony/http-kernel/Tests/EventListener/ExceptionListenerTest.php
index b607bf900a..3cb0b298bb 100644
--- a/vendor/symfony/http-kernel/Tests/EventListener/ExceptionListenerTest.php
+++ b/vendor/symfony/http-kernel/Tests/EventListener/ExceptionListenerTest.php
@@ -151,23 +151,6 @@ class ExceptionListenerTest extends TestCase
$this->assertFalse($response->headers->has('content-security-policy'), 'CSP header has been removed');
$this->assertFalse($dispatcher->hasListeners(KernelEvents::RESPONSE), 'CSP removal listener has been removed');
}
-
- public function testNullController()
- {
- $listener = new ExceptionListener(null);
- $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
- $kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) {
- $controller = $request->attributes->get('_controller');
-
- return $controller();
- }));
- $request = Request::create('/');
- $event = new GetResponseForExceptionEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new \Exception('foo'));
-
- $listener->onKernelException($event);
-
- $this->assertContains('Whoops, looks like something went wrong.', $event->getResponse()->getContent());
- }
}
class TestLogger extends Logger implements DebugLoggerInterface
diff --git a/vendor/symfony/http-kernel/Tests/EventListener/SessionListenerTest.php b/vendor/symfony/http-kernel/Tests/EventListener/SessionListenerTest.php
index 34598363c8..a6416e7f69 100644
--- a/vendor/symfony/http-kernel/Tests/EventListener/SessionListenerTest.php
+++ b/vendor/symfony/http-kernel/Tests/EventListener/SessionListenerTest.php
@@ -18,6 +18,7 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
+use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
use Symfony\Component\HttpKernel\EventListener\AbstractSessionListener;
use Symfony\Component\HttpKernel\EventListener\SessionListener;
use Symfony\Component\HttpKernel\HttpKernelInterface;
@@ -58,8 +59,7 @@ class SessionListenerTest extends TestCase
public function testResponseIsPrivate()
{
$session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock();
- $session->expects($this->once())->method('isStarted')->willReturn(false);
- $session->expects($this->once())->method('hasBeenStarted')->willReturn(true);
+ $session->expects($this->exactly(2))->method('getUsageIndex')->will($this->onConsecutiveCalls(0, 1));
$container = new Container();
$container->set('session', $session);
@@ -76,4 +76,38 @@ class SessionListenerTest extends TestCase
$this->assertTrue($response->headers->hasCacheControlDirective('must-revalidate'));
$this->assertSame('0', $response->headers->getCacheControlDirective('max-age'));
}
+
+ public function testSurrogateMasterRequestIsPublic()
+ {
+ $session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock();
+ $session->expects($this->exactly(4))->method('getUsageIndex')->will($this->onConsecutiveCalls(0, 1, 1, 1));
+
+ $container = new Container();
+ $container->set('session', $session);
+
+ $listener = new SessionListener($container);
+ $kernel = $this->getMockBuilder(HttpKernelInterface::class)->disableOriginalConstructor()->getMock();
+
+ $request = new Request();
+ $response = new Response();
+ $response->setCache(array('public' => true, 'max_age' => '30'));
+ $listener->onKernelRequest(new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST));
+ $this->assertTrue($request->hasSession());
+
+ $subRequest = clone $request;
+ $this->assertSame($request->getSession(), $subRequest->getSession());
+ $listener->onKernelRequest(new GetResponseEvent($kernel, $subRequest, HttpKernelInterface::MASTER_REQUEST));
+ $listener->onKernelResponse(new FilterResponseEvent($kernel, $subRequest, HttpKernelInterface::MASTER_REQUEST, $response));
+ $listener->onFinishRequest(new FinishRequestEvent($kernel, $subRequest, HttpKernelInterface::MASTER_REQUEST));
+
+ $this->assertFalse($response->headers->hasCacheControlDirective('private'));
+ $this->assertFalse($response->headers->hasCacheControlDirective('must-revalidate'));
+ $this->assertSame('30', $response->headers->getCacheControlDirective('max-age'));
+
+ $listener->onKernelResponse(new FilterResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response));
+
+ $this->assertTrue($response->headers->hasCacheControlDirective('private'));
+ $this->assertTrue($response->headers->hasCacheControlDirective('must-revalidate'));
+ $this->assertSame('0', $response->headers->getCacheControlDirective('max-age'));
+ }
}
diff --git a/vendor/symfony/http-kernel/Tests/EventListener/ValidateRequestListenerTest.php b/vendor/symfony/http-kernel/Tests/EventListener/ValidateRequestListenerTest.php
index d060943255..8016603180 100644
--- a/vendor/symfony/http-kernel/Tests/EventListener/ValidateRequestListenerTest.php
+++ b/vendor/symfony/http-kernel/Tests/EventListener/ValidateRequestListenerTest.php
@@ -21,6 +21,11 @@ use Symfony\Component\HttpKernel\KernelEvents;
class ValidateRequestListenerTest extends TestCase
{
+ protected function tearDown()
+ {
+ Request::setTrustedProxies(array(), -1);
+ }
+
/**
* @expectedException \Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException
*/
diff --git a/vendor/symfony/http-kernel/Tests/Fragment/InlineFragmentRendererTest.php b/vendor/symfony/http-kernel/Tests/Fragment/InlineFragmentRendererTest.php
index 18e55a5be0..8e81dd584e 100644
--- a/vendor/symfony/http-kernel/Tests/Fragment/InlineFragmentRendererTest.php
+++ b/vendor/symfony/http-kernel/Tests/Fragment/InlineFragmentRendererTest.php
@@ -212,16 +212,33 @@ class InlineFragmentRendererTest extends TestCase
public function testHeadersPossiblyResultingIn304AreNotAssignedToSubrequest()
{
$expectedSubRequest = Request::create('/');
- if (Request::HEADER_X_FORWARDED_FOR & Request::getTrustedHeaderSet()) {
- $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1'));
- $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1');
- }
+ $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1'));
+ $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1');
$strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest));
$request = Request::create('/', 'GET', array(), array(), array(), array('HTTP_IF_MODIFIED_SINCE' => 'Fri, 01 Jan 2016 00:00:00 GMT', 'HTTP_IF_NONE_MATCH' => '*'));
$strategy->render('/', $request);
}
+ public function testFirstTrustedProxyIsSetAsRemote()
+ {
+ Request::setTrustedProxies(array('1.1.1.1'), -1);
+
+ $expectedSubRequest = Request::create('/');
+ $expectedSubRequest->headers->set('Surrogate-Capability', 'abc="ESI/1.0"');
+ $expectedSubRequest->server->set('REMOTE_ADDR', '1.1.1.1');
+ $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1'));
+ $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1');
+
+ $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest));
+
+ $request = Request::create('/');
+ $request->headers->set('Surrogate-Capability', 'abc="ESI/1.0"');
+ $strategy->render('/', $request);
+
+ Request::setTrustedProxies(array(), -1);
+ }
+
/**
* Creates a Kernel expecting a request equals to $request
* Allows delta in comparison in case REQUEST_TIME changed by 1 second.
diff --git a/vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTest.php b/vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTest.php
index 2a9a30d9ca..0a77648003 100644
--- a/vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTest.php
+++ b/vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTest.php
@@ -11,9 +11,11 @@
namespace Symfony\Component\HttpKernel\Tests\HttpCache;
+use Symfony\Component\HttpKernel\HttpCache\Esi;
use Symfony\Component\HttpKernel\HttpCache\HttpCache;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\HttpKernel\HttpCache\Store;
use Symfony\Component\HttpKernel\HttpKernelInterface;
/**
@@ -1350,6 +1352,8 @@ class HttpCacheTest extends HttpCacheTestCase
$this->request('GET', '/', array('REMOTE_ADDR' => '10.0.0.1'));
$this->assertEquals($expected, Request::getTrustedProxies());
+
+ Request::setTrustedProxies(array(), -1);
}
public function getTrustedProxyData()
@@ -1465,6 +1469,42 @@ class HttpCacheTest extends HttpCacheTestCase
$this->assertHttpKernelIsNotCalled();
$this->assertSame('get', $this->response->getContent());
}
+
+ public function testUsesOriginalRequestForSurrogate()
+ {
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
+ $store = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\StoreInterface')->getMock();
+
+ $kernel
+ ->expects($this->exactly(2))
+ ->method('handle')
+ ->willReturnCallback(function (Request $request) {
+ $this->assertSame('127.0.0.1', $request->server->get('REMOTE_ADDR'));
+
+ return new Response();
+ });
+
+ $cache = new HttpCache($kernel,
+ $store,
+ new Esi()
+ );
+
+ $request = Request::create('/');
+ $request->server->set('REMOTE_ADDR', '10.0.0.1');
+
+ // Main request
+ $cache->handle($request, HttpKernelInterface::MASTER_REQUEST);
+
+ // Main request was now modified by HttpCache
+ // The surrogate will ask for the request using $this->cache->getRequest()
+ // which MUST return the original request so the surrogate
+ // can actually behave like a reverse proxy like e.g. Varnish would.
+ $this->assertSame('10.0.0.1', $cache->getRequest()->getClientIp());
+ $this->assertSame('10.0.0.1', $cache->getRequest()->server->get('REMOTE_ADDR'));
+
+ // Surrogate request
+ $cache->handle($request, HttpKernelInterface::SUB_REQUEST);
+ }
}
class TestKernel implements HttpKernelInterface
diff --git a/vendor/symfony/http-kernel/Tests/HttpKernelTest.php b/vendor/symfony/http-kernel/Tests/HttpKernelTest.php
index 7aed26aa59..09349970f4 100644
--- a/vendor/symfony/http-kernel/Tests/HttpKernelTest.php
+++ b/vendor/symfony/http-kernel/Tests/HttpKernelTest.php
@@ -349,6 +349,8 @@ class HttpKernelTest extends TestCase
$kernel = $this->getHttpKernel($dispatcher);
$kernel->handle($request, $kernel::MASTER_REQUEST, false);
+
+ Request::setTrustedProxies(array(), -1);
}
private function getHttpKernel(EventDispatcherInterface $eventDispatcher, $controller = null, RequestStack $requestStack = null, array $arguments = array())
diff --git a/vendor/symfony/http-kernel/Tests/KernelTest.php b/vendor/symfony/http-kernel/Tests/KernelTest.php
index a16ac37dee..7cde2ac5e2 100644
--- a/vendor/symfony/http-kernel/Tests/KernelTest.php
+++ b/vendor/symfony/http-kernel/Tests/KernelTest.php
@@ -902,6 +902,21 @@ EOF;
}
/**
+ * @group time-sensitive
+ */
+ public function testKernelStartTimeIsResetWhileBootingAlreadyBootedKernel()
+ {
+ $kernel = $this->getKernelForTest(array('initializeBundles'), true);
+ $kernel->boot();
+ $preReBoot = $kernel->getStartTime();
+
+ sleep(3600); //Intentionally large value to detect if ClockMock ever breaks
+ $kernel->reboot(null);
+
+ $this->assertGreaterThan($preReBoot, $kernel->getStartTime());
+ }
+
+ /**
* Returns a mock for the BundleInterface.
*
* @return BundleInterface
@@ -970,10 +985,10 @@ EOF;
return $kernel;
}
- protected function getKernelForTest(array $methods = array())
+ protected function getKernelForTest(array $methods = array(), $debug = false)
{
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest')
- ->setConstructorArgs(array('test', false))
+ ->setConstructorArgs(array('test', $debug))
->setMethods($methods)
->getMock();
$p = new \ReflectionProperty($kernel, 'rootDir');
diff --git a/vendor/symfony/http-kernel/composer.json b/vendor/symfony/http-kernel/composer.json
index 17c0544c62..585ab5b37d 100644
--- a/vendor/symfony/http-kernel/composer.json
+++ b/vendor/symfony/http-kernel/composer.json
@@ -18,7 +18,7 @@
"require": {
"php": "^5.5.9|>=7.0.8",
"symfony/event-dispatcher": "~2.8|~3.0|~4.0",
- "symfony/http-foundation": "^3.4.4|^4.0.4",
+ "symfony/http-foundation": "~3.4.12|~4.0.12|^4.1.1",
"symfony/debug": "~2.8|~3.0|~4.0",
"symfony/polyfill-ctype": "~1.8",
"psr/log": "~1.0"