upgraded dependencies
This commit is contained in:
@@ -41,7 +41,7 @@ abstract class AbstractSurrogate implements SurrogateInterface
|
||||
/**
|
||||
* Returns a new cache strategy instance.
|
||||
*
|
||||
* @return ResponseCacheStrategyInterface A ResponseCacheStrategyInterface instance
|
||||
* @return ResponseCacheStrategyInterface
|
||||
*/
|
||||
public function createCacheStrategy()
|
||||
{
|
||||
@@ -88,7 +88,7 @@ abstract class AbstractSurrogate implements SurrogateInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function handle(HttpCache $cache, $uri, $alt, $ignoreErrors)
|
||||
public function handle(HttpCache $cache, string $uri, string $alt, bool $ignoreErrors)
|
||||
{
|
||||
$subRequest = Request::create($uri, Request::METHOD_GET, [], $cache->getRequest()->cookies->all(), [], $cache->getRequest()->server->all());
|
||||
|
||||
|
2
vendor/symfony/http-kernel/HttpCache/Esi.php
vendored
2
vendor/symfony/http-kernel/HttpCache/Esi.php
vendored
@@ -45,7 +45,7 @@ class Esi extends AbstractSurrogate
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function renderIncludeTag($uri, $alt = null, $ignoreErrors = true, $comment = '')
|
||||
public function renderIncludeTag(string $uri, string $alt = null, bool $ignoreErrors = true, string $comment = '')
|
||||
{
|
||||
$html = sprintf('<esi:include src="%s"%s%s />',
|
||||
$uri,
|
||||
|
@@ -46,7 +46,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
* will try to carry on and deliver a meaningful response.
|
||||
*
|
||||
* * trace_level May be one of 'none', 'short' and 'full'. For 'short', a concise trace of the
|
||||
* master request will be added as an HTTP header. 'full' will add traces for all
|
||||
* main request will be added as an HTTP header. 'full' will add traces for all
|
||||
* requests (including ESI subrequests). (default: 'full' if in debug; 'none' otherwise)
|
||||
*
|
||||
* * trace_header Header name to use for traces. (default: X-Symfony-Cache)
|
||||
@@ -108,7 +108,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
/**
|
||||
* Gets the current store.
|
||||
*
|
||||
* @return StoreInterface A StoreInterface instance
|
||||
* @return StoreInterface
|
||||
*/
|
||||
public function getStore()
|
||||
{
|
||||
@@ -118,7 +118,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
/**
|
||||
* Returns an array of events that took place during processing of the last request.
|
||||
*
|
||||
* @return array An array of events
|
||||
* @return array
|
||||
*/
|
||||
public function getTraces()
|
||||
{
|
||||
@@ -145,7 +145,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
/**
|
||||
* Returns a log message for the events of the last request processing.
|
||||
*
|
||||
* @return string A log message
|
||||
* @return string
|
||||
*/
|
||||
public function getLog()
|
||||
{
|
||||
@@ -158,9 +158,9 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Request instance associated with the master request.
|
||||
* Gets the Request instance associated with the main request.
|
||||
*
|
||||
* @return Request A Request instance
|
||||
* @return Request
|
||||
*/
|
||||
public function getRequest()
|
||||
{
|
||||
@@ -170,7 +170,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
/**
|
||||
* Gets the Kernel instance.
|
||||
*
|
||||
* @return HttpKernelInterface An HttpKernelInterface instance
|
||||
* @return HttpKernelInterface
|
||||
*/
|
||||
public function getKernel()
|
||||
{
|
||||
@@ -180,7 +180,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
/**
|
||||
* Gets the Surrogate instance.
|
||||
*
|
||||
* @return SurrogateInterface A Surrogate instance
|
||||
* @return SurrogateInterface
|
||||
*
|
||||
* @throws \LogicException
|
||||
*/
|
||||
@@ -192,10 +192,10 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
|
||||
public function handle(Request $request, int $type = HttpKernelInterface::MAIN_REQUEST, bool $catch = true)
|
||||
{
|
||||
// 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) {
|
||||
if (HttpKernelInterface::MAIN_REQUEST === $type) {
|
||||
$this->traces = [];
|
||||
// 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
|
||||
@@ -226,12 +226,12 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
|
||||
$this->restoreResponseBody($request, $response);
|
||||
|
||||
if (HttpKernelInterface::MASTER_REQUEST === $type) {
|
||||
if (HttpKernelInterface::MAIN_REQUEST === $type) {
|
||||
$this->addTraces($response);
|
||||
}
|
||||
|
||||
if (null !== $this->surrogate) {
|
||||
if (HttpKernelInterface::MASTER_REQUEST === $type) {
|
||||
if (HttpKernelInterface::MAIN_REQUEST === $type) {
|
||||
$this->surrogateCacheStrategy->update($response);
|
||||
} else {
|
||||
$this->surrogateCacheStrategy->add($response);
|
||||
@@ -260,9 +260,9 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
*
|
||||
* @param bool $catch Whether to process exceptions
|
||||
*
|
||||
* @return Response A Response instance
|
||||
* @return Response
|
||||
*/
|
||||
protected function pass(Request $request, $catch = false)
|
||||
protected function pass(Request $request, bool $catch = false)
|
||||
{
|
||||
$this->record($request, 'pass');
|
||||
|
||||
@@ -274,13 +274,13 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
*
|
||||
* @param bool $catch Whether to process exceptions
|
||||
*
|
||||
* @return Response A Response instance
|
||||
* @return Response
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @see RFC2616 13.10
|
||||
*/
|
||||
protected function invalidate(Request $request, $catch = false)
|
||||
protected function invalidate(Request $request, bool $catch = false)
|
||||
{
|
||||
$response = $this->pass($request, $catch);
|
||||
|
||||
@@ -322,11 +322,11 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
*
|
||||
* @param bool $catch Whether to process exceptions
|
||||
*
|
||||
* @return Response A Response instance
|
||||
* @return Response
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function lookup(Request $request, $catch = false)
|
||||
protected function lookup(Request $request, bool $catch = false)
|
||||
{
|
||||
try {
|
||||
$entry = $this->store->lookup($request);
|
||||
@@ -371,9 +371,9 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
*
|
||||
* @param bool $catch Whether to process exceptions
|
||||
*
|
||||
* @return Response A Response instance
|
||||
* @return Response
|
||||
*/
|
||||
protected function validate(Request $request, Response $entry, $catch = false)
|
||||
protected function validate(Request $request, Response $entry, bool $catch = false)
|
||||
{
|
||||
$subRequest = clone $request;
|
||||
|
||||
@@ -434,9 +434,9 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
*
|
||||
* @param bool $catch Whether to process exceptions
|
||||
*
|
||||
* @return Response A Response instance
|
||||
* @return Response
|
||||
*/
|
||||
protected function fetch(Request $request, $catch = false)
|
||||
protected function fetch(Request $request, bool $catch = false)
|
||||
{
|
||||
$subRequest = clone $request;
|
||||
|
||||
@@ -467,16 +467,16 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
* @param bool $catch Whether to catch exceptions or not
|
||||
* @param Response|null $entry A Response instance (the stale entry if present, null otherwise)
|
||||
*
|
||||
* @return Response A Response instance
|
||||
* @return Response
|
||||
*/
|
||||
protected function forward(Request $request, $catch = false, Response $entry = null)
|
||||
protected function forward(Request $request, bool $catch = false, Response $entry = null)
|
||||
{
|
||||
if ($this->surrogate) {
|
||||
$this->surrogate->addSurrogateCapability($request);
|
||||
}
|
||||
|
||||
// always a "master" request (as the real master request can be in cache)
|
||||
$response = SubRequestHandler::handle($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, $catch);
|
||||
$response = SubRequestHandler::handle($this->kernel, $request, HttpKernelInterface::MAIN_REQUEST, $catch);
|
||||
|
||||
/*
|
||||
* Support stale-if-error given on Responses or as a config option.
|
||||
@@ -540,7 +540,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
/**
|
||||
* Checks whether the cache entry is "fresh enough" to satisfy the Request.
|
||||
*
|
||||
* @return bool true if the cache entry if fresh enough, false otherwise
|
||||
* @return bool
|
||||
*/
|
||||
protected function isFreshEnough(Request $request, Response $entry)
|
||||
{
|
||||
|
@@ -17,7 +17,7 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
* ResponseCacheStrategy knows how to compute the Response cache HTTP header
|
||||
* based on the different response cache headers.
|
||||
*
|
||||
* This implementation changes the master response TTL to the smallest TTL received
|
||||
* This implementation changes the main response TTL to the smallest TTL received
|
||||
* or force validation if one of the surrogates has validation cache strategy.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
|
2
vendor/symfony/http-kernel/HttpCache/Ssi.php
vendored
2
vendor/symfony/http-kernel/HttpCache/Ssi.php
vendored
@@ -42,7 +42,7 @@ class Ssi extends AbstractSurrogate
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function renderIncludeTag($uri, $alt = null, $ignoreErrors = true, $comment = '')
|
||||
public function renderIncludeTag(string $uri, string $alt = null, bool $ignoreErrors = true, string $comment = '')
|
||||
{
|
||||
return sprintf('<!--#include virtual="%s" -->', $uri);
|
||||
}
|
||||
|
37
vendor/symfony/http-kernel/HttpCache/Store.php
vendored
37
vendor/symfony/http-kernel/HttpCache/Store.php
vendored
@@ -25,8 +25,10 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
class Store implements StoreInterface
|
||||
{
|
||||
protected $root;
|
||||
/** @var \SplObjectStorage<Request, string> */
|
||||
private $keyCache;
|
||||
private $locks;
|
||||
/** @var array<string, resource> */
|
||||
private $locks = [];
|
||||
|
||||
/**
|
||||
* @throws \RuntimeException
|
||||
@@ -34,11 +36,10 @@ class Store implements StoreInterface
|
||||
public function __construct(string $root)
|
||||
{
|
||||
$this->root = $root;
|
||||
if (!file_exists($this->root) && !@mkdir($this->root, 0777, true) && !is_dir($this->root)) {
|
||||
if (!is_dir($this->root) && !@mkdir($this->root, 0777, true) && !is_dir($this->root)) {
|
||||
throw new \RuntimeException(sprintf('Unable to create the store directory (%s).', $this->root));
|
||||
}
|
||||
$this->keyCache = new \SplObjectStorage();
|
||||
$this->locks = [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,7 +67,7 @@ class Store implements StoreInterface
|
||||
|
||||
if (!isset($this->locks[$key])) {
|
||||
$path = $this->getPath($key);
|
||||
if (!file_exists(\dirname($path)) && false === @mkdir(\dirname($path), 0777, true) && !is_dir(\dirname($path))) {
|
||||
if (!is_dir(\dirname($path)) && false === @mkdir(\dirname($path), 0777, true) && !is_dir(\dirname($path))) {
|
||||
return $path;
|
||||
}
|
||||
$h = fopen($path, 'c');
|
||||
@@ -110,7 +111,7 @@ class Store implements StoreInterface
|
||||
return true; // shortcut if lock held by this process
|
||||
}
|
||||
|
||||
if (!file_exists($path = $this->getPath($key))) {
|
||||
if (!is_file($path = $this->getPath($key))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -125,7 +126,7 @@ class Store implements StoreInterface
|
||||
/**
|
||||
* Locates a cached Response for the Request provided.
|
||||
*
|
||||
* @return Response|null A Response instance, or null if no cache entry was found
|
||||
* @return Response|null
|
||||
*/
|
||||
public function lookup(Request $request)
|
||||
{
|
||||
@@ -166,7 +167,7 @@ class Store implements StoreInterface
|
||||
* Existing entries are read and any that match the response are removed. This
|
||||
* method calls write with the new list of cache entries.
|
||||
*
|
||||
* @return string The key under which the response is stored
|
||||
* @return string
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
@@ -207,7 +208,7 @@ class Store implements StoreInterface
|
||||
$entry[1]['vary'] = [''];
|
||||
}
|
||||
|
||||
if ($entry[1]['vary'][0] != $vary || !$this->requestsMatch($vary, $entry[0], $storedEnv)) {
|
||||
if ($entry[1]['vary'][0] != $vary || !$this->requestsMatch($vary ?? '', $entry[0], $storedEnv)) {
|
||||
$entries[] = $entry;
|
||||
}
|
||||
}
|
||||
@@ -265,9 +266,9 @@ class Store implements StoreInterface
|
||||
* Determines whether two Request HTTP header sets are non-varying based on
|
||||
* the vary response header value provided.
|
||||
*
|
||||
* @param string $vary A Response vary header
|
||||
* @param array $env1 A Request HTTP header array
|
||||
* @param array $env2 A Request HTTP header array
|
||||
* @param string|null $vary A Response vary header
|
||||
* @param array $env1 A Request HTTP header array
|
||||
* @param array $env2 A Request HTTP header array
|
||||
*/
|
||||
private function requestsMatch(?string $vary, array $env1, array $env2): bool
|
||||
{
|
||||
@@ -306,11 +307,9 @@ class Store implements StoreInterface
|
||||
*
|
||||
* This method purges both the HTTP and the HTTPS version of the cache entry.
|
||||
*
|
||||
* @param string $url A URL
|
||||
*
|
||||
* @return bool true if the URL exists with either HTTP or HTTPS scheme and has been purged, false otherwise
|
||||
*/
|
||||
public function purge($url)
|
||||
public function purge(string $url)
|
||||
{
|
||||
$http = preg_replace('#^https:#', 'http:', $url);
|
||||
$https = preg_replace('#^http:#', 'https:', $url);
|
||||
@@ -333,7 +332,7 @@ class Store implements StoreInterface
|
||||
unset($this->locks[$key]);
|
||||
}
|
||||
|
||||
if (file_exists($path = $this->getPath($key))) {
|
||||
if (is_file($path = $this->getPath($key))) {
|
||||
unlink($path);
|
||||
|
||||
return true;
|
||||
@@ -349,7 +348,7 @@ class Store implements StoreInterface
|
||||
{
|
||||
$path = $this->getPath($key);
|
||||
|
||||
return file_exists($path) && false !== ($contents = @file_get_contents($path)) ? $contents : null;
|
||||
return is_file($path) && false !== ($contents = @file_get_contents($path)) ? $contents : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -374,7 +373,7 @@ class Store implements StoreInterface
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!file_exists(\dirname($path)) && false === @mkdir(\dirname($path), 0777, true) && !is_dir(\dirname($path))) {
|
||||
if (!is_dir(\dirname($path)) && false === @mkdir(\dirname($path), 0777, true) && !is_dir(\dirname($path))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -405,7 +404,7 @@ class Store implements StoreInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getPath($key)
|
||||
public function getPath(string $key)
|
||||
{
|
||||
return $this->root.\DIRECTORY_SEPARATOR.substr($key, 0, 2).\DIRECTORY_SEPARATOR.substr($key, 2, 2).\DIRECTORY_SEPARATOR.substr($key, 4, 2).\DIRECTORY_SEPARATOR.substr($key, 6);
|
||||
}
|
||||
@@ -420,7 +419,7 @@ class Store implements StoreInterface
|
||||
* headers, use a Vary header to indicate them, and each representation will
|
||||
* be stored independently under the same cache key.
|
||||
*
|
||||
* @return string A key for the given Request
|
||||
* @return string
|
||||
*/
|
||||
protected function generateCacheKey(Request $request)
|
||||
{
|
||||
|
@@ -27,7 +27,7 @@ interface StoreInterface
|
||||
/**
|
||||
* Locates a cached Response for the Request provided.
|
||||
*
|
||||
* @return Response|null A Response instance, or null if no cache entry was found
|
||||
* @return Response|null
|
||||
*/
|
||||
public function lookup(Request $request);
|
||||
|
||||
@@ -70,11 +70,9 @@ interface StoreInterface
|
||||
/**
|
||||
* Purges data for the given URL.
|
||||
*
|
||||
* @param string $url A URL
|
||||
*
|
||||
* @return bool true if the URL exists and has been purged, false otherwise
|
||||
*/
|
||||
public function purge($url);
|
||||
public function purge(string $url);
|
||||
|
||||
/**
|
||||
* Cleanups storage.
|
||||
|
@@ -23,7 +23,7 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
*/
|
||||
class SubRequestHandler
|
||||
{
|
||||
public static function handle(HttpKernelInterface $kernel, Request $request, $type, $catch): Response
|
||||
public static function handle(HttpKernelInterface $kernel, Request $request, int $type, bool $catch): Response
|
||||
{
|
||||
// save global state related to trusted headers and proxies
|
||||
$trustedProxies = Request::getTrustedProxies();
|
||||
@@ -31,13 +31,14 @@ class SubRequestHandler
|
||||
|
||||
// remove untrusted values
|
||||
$remoteAddr = $request->server->get('REMOTE_ADDR');
|
||||
if (!IpUtils::checkIp($remoteAddr, $trustedProxies)) {
|
||||
if (!$remoteAddr || !IpUtils::checkIp($remoteAddr, $trustedProxies)) {
|
||||
$trustedHeaders = [
|
||||
'FORWARDED' => $trustedHeaderSet & Request::HEADER_FORWARDED,
|
||||
'X_FORWARDED_FOR' => $trustedHeaderSet & Request::HEADER_X_FORWARDED_FOR,
|
||||
'X_FORWARDED_HOST' => $trustedHeaderSet & Request::HEADER_X_FORWARDED_HOST,
|
||||
'X_FORWARDED_PROTO' => $trustedHeaderSet & Request::HEADER_X_FORWARDED_PROTO,
|
||||
'X_FORWARDED_PORT' => $trustedHeaderSet & Request::HEADER_X_FORWARDED_PORT,
|
||||
'X_FORWARDED_PREFIX' => $trustedHeaderSet & Request::HEADER_X_FORWARDED_PREFIX,
|
||||
];
|
||||
foreach (array_filter($trustedHeaders) as $name => $key) {
|
||||
$request->headers->remove($name);
|
||||
|
@@ -26,14 +26,14 @@ interface SurrogateInterface
|
||||
/**
|
||||
* Returns a new cache strategy instance.
|
||||
*
|
||||
* @return ResponseCacheStrategyInterface A ResponseCacheStrategyInterface instance
|
||||
* @return ResponseCacheStrategyInterface
|
||||
*/
|
||||
public function createCacheStrategy();
|
||||
|
||||
/**
|
||||
* Checks that at least one surrogate has Surrogate capability.
|
||||
*
|
||||
* @return bool true if one surrogate has Surrogate capability, false otherwise
|
||||
* @return bool
|
||||
*/
|
||||
public function hasSurrogateCapability(Request $request);
|
||||
|
||||
@@ -52,21 +52,19 @@ interface SurrogateInterface
|
||||
/**
|
||||
* Checks that the Response needs to be parsed for Surrogate tags.
|
||||
*
|
||||
* @return bool true if the Response needs to be parsed, false otherwise
|
||||
* @return bool
|
||||
*/
|
||||
public function needsParsing(Response $response);
|
||||
|
||||
/**
|
||||
* Renders a Surrogate tag.
|
||||
*
|
||||
* @param string $uri A URI
|
||||
* @param string $alt An alternate URI
|
||||
* @param bool $ignoreErrors Whether to ignore errors or not
|
||||
* @param string $comment A comment to add as an esi:include tag
|
||||
* @param string $alt An alternate URI
|
||||
* @param string $comment A comment to add as an esi:include tag
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function renderIncludeTag($uri, $alt = null, $ignoreErrors = true, $comment = '');
|
||||
public function renderIncludeTag(string $uri, string $alt = null, bool $ignoreErrors = true, string $comment = '');
|
||||
|
||||
/**
|
||||
* Replaces a Response Surrogate tags with the included resource content.
|
||||
@@ -78,14 +76,12 @@ interface SurrogateInterface
|
||||
/**
|
||||
* Handles a Surrogate from the cache.
|
||||
*
|
||||
* @param string $uri The main URI
|
||||
* @param string $alt An alternative URI
|
||||
* @param bool $ignoreErrors Whether to ignore errors or not
|
||||
* @param string $alt An alternative URI
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function handle(HttpCache $cache, $uri, $alt, $ignoreErrors);
|
||||
public function handle(HttpCache $cache, string $uri, string $alt, bool $ignoreErrors);
|
||||
}
|
||||
|
Reference in New Issue
Block a user