From 0a9f741da0ade63515fc27a91f3f57c62ecbef31 Mon Sep 17 00:00:00 2001 From: Martin Ficzel Date: Thu, 5 May 2022 14:20:40 +0200 Subject: [PATCH] TASK: Adjust guzzle requirements to be in line with neos 8 and use flushByTags --- Classes/Aspects/ContentCacheAspect.php | 6 ++---- Classes/Middleware/RequestCacheMiddleware.php | 6 +++--- composer.json | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Classes/Aspects/ContentCacheAspect.php b/Classes/Aspects/ContentCacheAspect.php index 871650f..2deddcd 100644 --- a/Classes/Aspects/ContentCacheAspect.php +++ b/Classes/Aspects/ContentCacheAspect.php @@ -46,10 +46,8 @@ public function interceptNodeCacheFlush(JoinPointInterface $joinPoint) $object = $joinPoint->getProxy(); $tags = ObjectAccess::getProperty($object, 'tagsToFlush', true); - foreach ($tags as $tag => $_) { - $tag = $this->sanitizeTag($tag); - $this->cacheFrontend->flushByTag($tag); - } + $tags = array_map([$this, 'sanitizeTag'],$tags); + $this->cacheFrontend->flushByTags($tags); } /** diff --git a/Classes/Middleware/RequestCacheMiddleware.php b/Classes/Middleware/RequestCacheMiddleware.php index e4e209d..dd9c6dc 100644 --- a/Classes/Middleware/RequestCacheMiddleware.php +++ b/Classes/Middleware/RequestCacheMiddleware.php @@ -9,7 +9,7 @@ use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\RequestHandlerInterface; -use function GuzzleHttp\Psr7\parse_response; +use GuzzleHttp\Psr7\Message; use function GuzzleHttp\Psr7\str; class RequestCacheMiddleware implements MiddlewareInterface @@ -72,7 +72,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface if ($cacheEntry = $this->cacheFrontend->get($entryIdentifier)) { $age = time() - $cacheEntry['timestamp']; - $response = parse_response($cacheEntry['response']); + $response = Message::parseResponse($cacheEntry['response']); return $response ->withHeader('Age', $age) ->withHeader(self::HEADER_INFO, 'HIT: ' . $entryIdentifier); @@ -105,7 +105,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface ->withHeader('Cache-Control', 'public, max-age=' . $publicLifetime); } - $this->cacheFrontend->set($entryIdentifier,[ 'timestamp' => time(), 'response' => str($response) ], $tags, $lifetime); + $this->cacheFrontend->set($entryIdentifier,[ 'timestamp' => time(), 'response' => Message::toString($response) ], $tags, $lifetime); $response->getBody()->rewind(); return $response->withHeader(self::HEADER_INFO, 'MISS: ' . $entryIdentifier); } diff --git a/composer.json b/composer.json index 1cd83b6..bcdbb31 100644 --- a/composer.json +++ b/composer.json @@ -4,8 +4,8 @@ "name": "flowpack/fullpagecache", "license": "MIT", "require": { - "neos/neos": "^7.0 || ^8.0 || dev-master", - "guzzlehttp/psr7": "~1.4" + "neos/neos": "^8.0 || dev-master", + "guzzlehttp/psr7": "^1.7, !=1.8.0 || ~2.0" }, "autoload": { "psr-4": {