From a678dce74de5f616932a67a04be2502c29e20e77 Mon Sep 17 00:00:00 2001 From: David Steeb Date: Fri, 25 Sep 2026 18:40:17 +0200 Subject: [PATCH] [BUGFIX] Resolve cached URLs through the cache frontend Since 5.0.1 resolveCachedUrl() reads entries via the backend's own get(), which returns the HMAC-signed serialization written by the VariableFrontend instead of the URL. Providers cannot parse a host from it, so flushByTag()/flushByTags() purged nothing when content was saved; only flush() worked, as it does not need the URLs. Keep a reference to the frontend in setCache() and resolve URLs through it. Plain URLs from rows written before 5.0.0 still work through the existing fallback. --- .../Cache/Backend/ReverseProxyCacheBackend.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Classes/Cache/Backend/ReverseProxyCacheBackend.php b/Classes/Cache/Backend/ReverseProxyCacheBackend.php index 471bc8e..582f6fa 100755 --- a/Classes/Cache/Backend/ReverseProxyCacheBackend.php +++ b/Classes/Cache/Backend/ReverseProxyCacheBackend.php @@ -20,6 +20,7 @@ use B13\Proxycachemanager\Provider\ProxyProviderInterface; use Psr\Log\LoggerAwareTrait; use TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend; +use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -32,6 +33,17 @@ class ReverseProxyCacheBackend extends Typo3DatabaseBackend { use LoggerAwareTrait; protected ProxyProviderInterface $reverseProxyProvider; + protected ?FrontendInterface $frontend = null; + + /** + * Keep a reference to the frontend: entries are serialized (and HMAC-signed) + * by the VariableFrontend, so only the frontend can turn them back into URLs. + */ + public function setCache(FrontendInterface $cache): void + { + parent::setCache($cache); + $this->frontend = $cache; + } public function setReverseProxyProvider(ProxyProviderInterface $reverseProxyProvider) { @@ -131,15 +143,15 @@ protected function getAllCachedUrls(): array * contract is incompatible with Typo3DatabaseBackend), the configured * VariableFrontend serializes — and on v13.4+ HMAC-signs — every entry before * it is written to the database. Reads must therefore go through the frontend - * to obtain the original URL again; a raw column read would only yield the - * serialized blob. + * to obtain the original URL again; the backend's own get() only yields the + * serialized blob, which contains no parseable host and is dropped by providers. * * Rows written by older versions (TransientBackendInterface era) still hold the * plain URL and fail deserialization, so we fall back to the raw value for those. */ protected function resolveCachedUrl(string $entryIdentifier, ?string $rawContent = null): ?string { - $url = $this->get($entryIdentifier); + $url = $this->frontend?->get($entryIdentifier); if (is_string($url) && $url !== '') { return $url; }