Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions Classes/Cache/Backend/ReverseProxyCacheBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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)
{
Expand Down Expand Up @@ -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;
}
Expand Down
Loading