composer update
This commit is contained in:
@@ -109,6 +109,8 @@ abstract class AbstractSurrogate implements SurrogateInterface
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
2
vendor/symfony/http-kernel/HttpCache/Esi.php
vendored
2
vendor/symfony/http-kernel/HttpCache/Esi.php
vendored
@@ -111,5 +111,7 @@ class Esi extends AbstractSurrogate
|
||||
|
||||
// remove ESI/1.0 from the Surrogate-Control header
|
||||
$this->removeFromControl($response);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,8 +98,8 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
'trace_header' => 'X-Symfony-Cache',
|
||||
], $options);
|
||||
|
||||
if (!isset($options['trace_level']) && $this->options['debug']) {
|
||||
$this->options['trace_level'] = 'full';
|
||||
if (!isset($options['trace_level'])) {
|
||||
$this->options['trace_level'] = $this->options['debug'] ? 'full' : 'none';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
|
||||
$this->traces[$this->getTraceKey($request)] = [];
|
||||
|
||||
if (!$request->isMethodSafe(false)) {
|
||||
if (!$request->isMethodSafe()) {
|
||||
$response = $this->invalidate($request, $catch);
|
||||
} elseif ($request->headers->has('expect') || !$request->isMethodCacheable()) {
|
||||
$response = $this->pass($request, $catch);
|
||||
@@ -256,8 +256,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
/**
|
||||
* Forwards the Request to the backend without storing the Response in the cache.
|
||||
*
|
||||
* @param Request $request A Request instance
|
||||
* @param bool $catch Whether to process exceptions
|
||||
* @param bool $catch Whether to process exceptions
|
||||
*
|
||||
* @return Response A Response instance
|
||||
*/
|
||||
@@ -271,8 +270,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
/**
|
||||
* Invalidates non-safe methods (like POST, PUT, and DELETE).
|
||||
*
|
||||
* @param Request $request A Request instance
|
||||
* @param bool $catch Whether to process exceptions
|
||||
* @param bool $catch Whether to process exceptions
|
||||
*
|
||||
* @return Response A Response instance
|
||||
*
|
||||
@@ -320,8 +318,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
* the backend using conditional GET. When no matching cache entry is found,
|
||||
* it triggers "miss" processing.
|
||||
*
|
||||
* @param Request $request A Request instance
|
||||
* @param bool $catch Whether to process exceptions
|
||||
* @param bool $catch Whether to process exceptions
|
||||
*
|
||||
* @return Response A Response instance
|
||||
*
|
||||
@@ -366,9 +363,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
* The original request is used as a template for a conditional
|
||||
* GET request with the backend.
|
||||
*
|
||||
* @param Request $request A Request instance
|
||||
* @param Response $entry A Response instance to validate
|
||||
* @param bool $catch Whether to process exceptions
|
||||
* @param bool $catch Whether to process exceptions
|
||||
*
|
||||
* @return Response A Response instance
|
||||
*/
|
||||
@@ -429,8 +424,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
* Unconditionally fetches a fresh response from the backend and
|
||||
* stores it in the cache if is cacheable.
|
||||
*
|
||||
* @param Request $request A Request instance
|
||||
* @param bool $catch Whether to process exceptions
|
||||
* @param bool $catch Whether to process exceptions
|
||||
*
|
||||
* @return Response A Response instance
|
||||
*/
|
||||
@@ -462,9 +456,8 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
* All backend requests (cache passes, fetches, cache validations)
|
||||
* run through this method.
|
||||
*
|
||||
* @param Request $request A Request instance
|
||||
* @param bool $catch Whether to catch exceptions or not
|
||||
* @param Response $entry A Response instance (the stale entry if present, null otherwise)
|
||||
* @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
|
||||
*/
|
||||
@@ -642,10 +635,8 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
/**
|
||||
* Checks if the Request includes authorization or other sensitive information
|
||||
* that should cause the Response to be considered private by default.
|
||||
*
|
||||
* @return bool true if the Request is private, false otherwise
|
||||
*/
|
||||
private function isPrivateRequest(Request $request)
|
||||
private function isPrivateRequest(Request $request): bool
|
||||
{
|
||||
foreach ($this->options['private_headers'] as $key) {
|
||||
$key = strtolower(str_replace('HTTP_', '', $key));
|
||||
|
||||
@@ -130,7 +130,6 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
|
||||
$response->headers->set('Cache-Control', implode(', ', array_keys($flags)));
|
||||
|
||||
$maxAge = null;
|
||||
$sMaxage = null;
|
||||
|
||||
if (is_numeric($this->ageDirectives['max-age'])) {
|
||||
$maxAge = $this->ageDirectives['max-age'] + $this->age;
|
||||
@@ -156,10 +155,8 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
|
||||
* RFC2616, Section 13.4.
|
||||
*
|
||||
* @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.4
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function willMakeFinalResponseUncacheable(Response $response)
|
||||
private function willMakeFinalResponseUncacheable(Response $response): bool
|
||||
{
|
||||
// RFC2616: A response received with a status code of 200, 203, 300, 301 or 410
|
||||
// MAY be stored by a cache […] unless a cache-control directive prohibits caching.
|
||||
@@ -203,12 +200,8 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
|
||||
*
|
||||
* If the value is lower than the currently stored value, we update the value, to keep a rolling
|
||||
* minimal value of each instruction. If the value is NULL, the directive will not be set on the final response.
|
||||
*
|
||||
* @param string $directive
|
||||
* @param int|null $value
|
||||
* @param int $age
|
||||
*/
|
||||
private function storeRelativeAgeDirective($directive, $value, $age)
|
||||
private function storeRelativeAgeDirective(string $directive, ?int $value, int $age)
|
||||
{
|
||||
if (null === $value) {
|
||||
$this->ageDirectives[$directive] = false;
|
||||
|
||||
2
vendor/symfony/http-kernel/HttpCache/Ssi.php
vendored
2
vendor/symfony/http-kernel/HttpCache/Ssi.php
vendored
@@ -94,5 +94,7 @@ class Ssi extends AbstractSurrogate
|
||||
|
||||
// remove SSI/1.0 from the Surrogate-Control header
|
||||
$this->removeFromControl($response);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
63
vendor/symfony/http-kernel/HttpCache/Store.php
vendored
63
vendor/symfony/http-kernel/HttpCache/Store.php
vendored
@@ -132,7 +132,7 @@ class Store implements StoreInterface
|
||||
$key = $this->getCacheKey($request);
|
||||
|
||||
if (!$entries = $this->getMetadata($key)) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
// find a cached entry that matches the request.
|
||||
@@ -146,7 +146,7 @@ class Store implements StoreInterface
|
||||
}
|
||||
|
||||
if (null === $match) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$headers = $match[1];
|
||||
@@ -157,6 +157,7 @@ class Store implements StoreInterface
|
||||
// TODO the metaStore referenced an entity that doesn't exist in
|
||||
// the entityStore. We definitely want to return nil but we should
|
||||
// also purge the entry from the meta-store when this is detected.
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,7 +179,7 @@ class Store implements StoreInterface
|
||||
if (!$response->headers->has('X-Content-Digest')) {
|
||||
$digest = $this->generateContentDigest($response);
|
||||
|
||||
if (false === $this->save($digest, $response->getContent())) {
|
||||
if (!$this->save($digest, $response->getContent())) {
|
||||
throw new \RuntimeException('Unable to store the entity.');
|
||||
}
|
||||
|
||||
@@ -207,7 +208,7 @@ class Store implements StoreInterface
|
||||
|
||||
array_unshift($entries, [$storedEnv, $headers]);
|
||||
|
||||
if (false === $this->save($key, serialize($entries))) {
|
||||
if (!$this->save($key, serialize($entries))) {
|
||||
throw new \RuntimeException('Unable to store the metadata.');
|
||||
}
|
||||
|
||||
@@ -246,7 +247,7 @@ class Store implements StoreInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ($modified && false === $this->save($key, serialize($entries))) {
|
||||
if ($modified && !$this->save($key, serialize($entries))) {
|
||||
throw new \RuntimeException('Unable to store the metadata.');
|
||||
}
|
||||
}
|
||||
@@ -258,10 +259,8 @@ class Store implements StoreInterface
|
||||
* @param string $vary A Response vary header
|
||||
* @param array $env1 A Request HTTP header array
|
||||
* @param array $env2 A Request HTTP header array
|
||||
*
|
||||
* @return bool true if the two environments match, false otherwise
|
||||
*/
|
||||
private function requestsMatch($vary, $env1, $env2)
|
||||
private function requestsMatch(?string $vary, array $env1, array $env2): bool
|
||||
{
|
||||
if (empty($vary)) {
|
||||
return true;
|
||||
@@ -283,12 +282,8 @@ class Store implements StoreInterface
|
||||
* Gets all data associated with the given key.
|
||||
*
|
||||
* Use this method only if you know what you are doing.
|
||||
*
|
||||
* @param string $key The store key
|
||||
*
|
||||
* @return array An array of data associated with the key
|
||||
*/
|
||||
private function getMetadata($key)
|
||||
private function getMetadata(string $key): array
|
||||
{
|
||||
if (!$entries = $this->load($key)) {
|
||||
return [];
|
||||
@@ -319,12 +314,8 @@ class Store implements 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
|
||||
*/
|
||||
private function doPurge($url)
|
||||
private function doPurge(string $url): bool
|
||||
{
|
||||
$key = $this->getCacheKey(Request::create($url));
|
||||
if (isset($this->locks[$key])) {
|
||||
@@ -344,27 +335,18 @@ class Store implements StoreInterface
|
||||
|
||||
/**
|
||||
* Loads data for the given key.
|
||||
*
|
||||
* @param string $key The store key
|
||||
*
|
||||
* @return string The data associated with the key
|
||||
*/
|
||||
private function load($key)
|
||||
private function load(string $key): ?string
|
||||
{
|
||||
$path = $this->getPath($key);
|
||||
|
||||
return file_exists($path) ? file_get_contents($path) : false;
|
||||
return file_exists($path) && false !== ($contents = file_get_contents($path)) ? $contents : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save data for the given key.
|
||||
*
|
||||
* @param string $key The store key
|
||||
* @param string $data The data to store
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function save($key, $data)
|
||||
private function save(string $key, string $data): bool
|
||||
{
|
||||
$path = $this->getPath($key);
|
||||
|
||||
@@ -406,6 +388,8 @@ class Store implements StoreInterface
|
||||
}
|
||||
|
||||
@chmod($path, 0666 & ~umask());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getPath($key)
|
||||
@@ -432,10 +416,8 @@ class Store implements StoreInterface
|
||||
|
||||
/**
|
||||
* Returns a cache key for the given Request.
|
||||
*
|
||||
* @return string A key for the given Request
|
||||
*/
|
||||
private function getCacheKey(Request $request)
|
||||
private function getCacheKey(Request $request): string
|
||||
{
|
||||
if (isset($this->keyCache[$request])) {
|
||||
return $this->keyCache[$request];
|
||||
@@ -446,20 +428,16 @@ class Store implements StoreInterface
|
||||
|
||||
/**
|
||||
* Persists the Request HTTP headers.
|
||||
*
|
||||
* @return array An array of HTTP headers
|
||||
*/
|
||||
private function persistRequest(Request $request)
|
||||
private function persistRequest(Request $request): array
|
||||
{
|
||||
return $request->headers->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Persists the Response HTTP headers.
|
||||
*
|
||||
* @return array An array of HTTP headers
|
||||
*/
|
||||
private function persistResponse(Response $response)
|
||||
private function persistResponse(Response $response): array
|
||||
{
|
||||
$headers = $response->headers->all();
|
||||
$headers['X-Status'] = [$response->getStatusCode()];
|
||||
@@ -469,13 +447,8 @@ class Store implements StoreInterface
|
||||
|
||||
/**
|
||||
* Restores a Response from the HTTP headers and body.
|
||||
*
|
||||
* @param array $headers An array of HTTP headers for the Response
|
||||
* @param string $body The Response body
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
private function restoreResponse($headers, $body = null)
|
||||
private function restoreResponse(array $headers, string $body = null): Response
|
||||
{
|
||||
$status = $headers['X-Status'][0];
|
||||
unset($headers['X-Status']);
|
||||
|
||||
@@ -78,10 +78,9 @@ interface SurrogateInterface
|
||||
/**
|
||||
* Handles a Surrogate from the cache.
|
||||
*
|
||||
* @param HttpCache $cache An HttpCache instance
|
||||
* @param string $uri The main URI
|
||||
* @param string $alt An alternative URI
|
||||
* @param bool $ignoreErrors Whether to ignore errors or not
|
||||
* @param string $uri The main URI
|
||||
* @param string $alt An alternative URI
|
||||
* @param bool $ignoreErrors Whether to ignore errors or not
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user