File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010use Psr \Log \LoggerAwareInterface ;
1111use Psr \Log \LoggerAwareTrait ;
1212use TYPO3 \CMS \Core \Cache \Backend \NullBackend ;
13+ use TYPO3 \CMS \Core \Cache \CacheTag ;
1314use TYPO3 \CMS \Core \Utility \GeneralUtility ;
15+ use function array_map ;
1416
1517class FastlyBackend extends NullBackend implements LoggerAwareInterface
1618{
@@ -63,6 +65,16 @@ public function flushByTags(array $tags): void
6365 if ($ fastlyService === null ) {
6466 return ;
6567 }
66- $ fastlyService ->purgeKeys ($ tags );
68+
69+ $ tagStrings = [];
70+ foreach ($ tags as $ tag ) {
71+ if ($ tag instanceof CacheTag) {
72+ $ tagStrings [] = $ tag ->name ;
73+ } else {
74+ $ tagStrings [] = (string )$ tag ;
75+ }
76+ }
77+
78+ $ fastlyService ->purgeKeys ($ tagStrings );
6779 }
6880}
Original file line number Diff line number Diff line change 88use Psr \Http \Message \ServerRequestInterface ;
99use Psr \Http \Server \MiddlewareInterface ;
1010use Psr \Http \Server \RequestHandlerInterface ;
11+ use TYPO3 \CMS \Core \Cache \CacheTag ;
1112use TYPO3 \CMS \Core \Http \ApplicationType ;
13+ use function array_map ;
1214use function array_unique ;
1315use function implode ;
1416use function is_array ;
@@ -63,11 +65,22 @@ protected function isFastlyDisabledOrNotConfigured(): bool
6365
6466 protected function appendSurrogateKeys (ResponseInterface $ response ): ResponseInterface
6567 {
66- if ( is_array ( $ GLOBALS [ ' TYPO3_REQUEST ' ]-> getAttribute ( ' frontend.cache.collector ' )-> getCacheTags ()) && $ GLOBALS ['TYPO3_REQUEST ' ]->getAttribute ('frontend.cache.collector ' )->getCacheTags () !== []) {
67- $ cacheTags = implode ( ' ' , array_unique ( $ GLOBALS [ ' TYPO3_REQUEST ' ]-> getAttribute ( ' frontend.cache.collector ' )-> getCacheTags ()));
68- $ response = $ response-> withHeader ( ' Surrogate-Key ' , $ cacheTags ) ;
68+ $ cacheTagObjects = $ GLOBALS ['TYPO3_REQUEST ' ]->getAttribute ('frontend.cache.collector ' )->getCacheTags ();
69+ if (! is_array ( $ cacheTagObjects ) || $ cacheTagObjects === []) {
70+ return $ response ;
6971 }
70- return $ response ;
72+
73+ $ cacheTagStrings = [];
74+ foreach ($ cacheTagObjects as $ tag ) {
75+ if ($ tag instanceof CacheTag) {
76+ $ cacheTagStrings [] = $ tag ->name ;
77+ } else {
78+ $ cacheTagStrings [] = (string )$ tag ;
79+ }
80+ }
81+
82+ $ cacheTags = implode (' ' , array_unique ($ cacheTagStrings ));
83+ return $ response ->withHeader ('Surrogate-Key ' , $ cacheTags );
7184 }
7285
7386 protected function appendSurrogateControl (ResponseInterface $ response ): ResponseInterface
You can’t perform that action at this time.
0 commit comments