diff --git a/Classes/Cache/Backend/ReverseProxyCacheBackend.php b/Classes/Cache/Backend/ReverseProxyCacheBackend.php
index 2683af0..6fa920a 100755
--- a/Classes/Cache/Backend/ReverseProxyCacheBackend.php
+++ b/Classes/Cache/Backend/ReverseProxyCacheBackend.php
@@ -19,7 +19,6 @@
use B13\Proxycachemanager\Provider\ProxyProviderInterface;
use Psr\Log\LoggerAwareTrait;
-use TYPO3\CMS\Core\Cache\Backend\TransientBackendInterface;
use TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -29,7 +28,7 @@
* when removing or flushing, additionally does a HTTP Request
* of course "setting" works naturally in am already working reverse proxy environment.
*/
-class ReverseProxyCacheBackend extends Typo3DatabaseBackend implements TransientBackendInterface
+class ReverseProxyCacheBackend extends Typo3DatabaseBackend
{
use LoggerAwareTrait;
protected ProxyProviderInterface $reverseProxyProvider;
@@ -39,30 +38,11 @@ public function setReverseProxyProvider(ProxyProviderInterface $reverseProxyProv
$this->reverseProxyProvider = $reverseProxyProvider;
}
- /**
- * Removes all cache entries matching the specified identifier.
- * Usually this only affects one entry.
- *
- * Please note: As remove() is called when using set() in the parent method,
- * it would also flush the cache when the FE is accessed, resulting in a lot of
- * cache entries. This should be avoided, for this reason, we do not call the
- * provider anymore. Ideally we should not invalidate but rather push this actively
- * to the proxy in the future.
- *
- * @param string $entryIdentifier Specifies the cache entry to remove
- *
- * @return bool TRUE if (at least) an entry could be removed or FALSE if no entry was found
- */
- public function remove($entryIdentifier)
- {
- return parent::remove($entryIdentifier);
- }
-
/**
* Removes all cache entries of this cache.
* Also let the proxy provider know to clear everything as well.
*/
- public function flush()
+ public function flush(): void
{
// make the HTTP Purge call
if ($this->reverseProxyProvider->isActive()) {
@@ -77,7 +57,7 @@ public function flush()
*
* @param string $tag The tag the entries must have
*/
- public function flushByTag($tag)
+ public function flushByTag($tag): void
{
if ($this->reverseProxyProvider->isActive()) {
$identifiers = $this->findIdentifiersByTag($tag);
@@ -97,7 +77,7 @@ public function flushByTag($tag)
*
* @param string[] $tags
*/
- public function flushByTags(array $tags)
+ public function flushByTags(array $tags): void
{
if ($this->reverseProxyProvider->isActive()) {
$identifiers = [];
diff --git a/Classes/Controller/ManagementController.php b/Classes/Controller/ManagementController.php
index 863aa93..0fdbac4 100644
--- a/Classes/Controller/ManagementController.php
+++ b/Classes/Controller/ManagementController.php
@@ -23,8 +23,6 @@
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Http\RedirectResponse;
-use TYPO3\CMS\Core\Information\Typo3Version;
-use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
@@ -41,78 +39,45 @@ public function __construct(protected ModuleTemplateFactory $moduleTemplateFacto
public function indexAction(): ResponseInterface
{
$moduleTemplate = $this->moduleTemplateFactory->create($this->request);
- if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 11) {
- $this->view->setTemplateRootPaths(['EXT:proxycachemanager/Resources/Private/TemplatesV11/']);
- $moduleTemplate->setContent($this->view->render());
- $response = $this->htmlResponse($moduleTemplate->renderContent());
- } else {
- $response = $moduleTemplate->renderResponse('Management/Index');
- }
- return $response;
+ return $moduleTemplate->renderResponse('Management/Index');
}
- /**
- * @param string $tag
- */
public function clearTagAction(string $tag): ResponseInterface
{
GeneralUtility::makeInstance(CacheManager::class)->flushCachesByTags([htmlspecialchars($tag)]);
- if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 11) {
- $severity = AbstractMessage::OK;
- } else {
- $severity = ContextualFeedbackSeverity::OK;
- }
$this->addFlashMessage(
'Successfully purged cache tag "' . htmlspecialchars($tag) . '".',
'Cache flushed',
- $severity
+ ContextualFeedbackSeverity::OK
);
return new RedirectResponse($this->uriBuilder->reset()->uriFor('index'));
}
- /**
- * @param string $url
- */
public function purgeUrlAction(string $url): ResponseInterface
{
if (empty($url)) {
- if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 11) {
- $severity = AbstractMessage::WARNING;
- } else {
- $severity = ContextualFeedbackSeverity::WARNING;
- }
$this->addFlashMessage(
'Please specify url',
'Cache not flushed',
- $severity
+ ContextualFeedbackSeverity::WARNING
);
return new RedirectResponse($this->uriBuilder->reset()->uriFor('index'));
}
$url = htmlspecialchars($url);
if (!$this->proxyProvider->isActive()) {
- if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 11) {
- $severity = AbstractMessage::ERROR;
- } else {
- $severity = ContextualFeedbackSeverity::ERROR;
- }
$this->addFlashMessage(
'Attempting to purge URL "' . $url . '". No active provider configured.',
'Cache not flushed',
- $severity
+ ContextualFeedbackSeverity::ERROR
);
return new RedirectResponse($this->uriBuilder->reset()->uriFor('index'));
}
$this->proxyProvider->flushCacheForUrls([$url]);
- if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 11) {
- $severity = AbstractMessage::OK;
- } else {
- $severity = ContextualFeedbackSeverity::OK;
- }
$this->addFlashMessage(
'Successfully purged URL "' . $url . '".',
'Cache flushed',
- $severity
+ ContextualFeedbackSeverity::OK
);
return new RedirectResponse($this->uriBuilder->reset()->uriFor('index'));
}
diff --git a/Classes/Hook/FrontendHook.php b/Classes/Hook/FrontendHook.php
deleted file mode 100755
index ec26ffc..0000000
--- a/Classes/Hook/FrontendHook.php
+++ /dev/null
@@ -1,62 +0,0 @@
-proxyProvider = $configuration->getProxyProvider();
- }
-
- /**
- * Hook that is called when a cacheable page was just added to the cache system
- * calls the proxy cache and stores the pageId, the URL
- * this call costs a little bit of performance but is only called
- * once (!) as the URL is cacheable, next time it is fetched
- * from the reverse proxy directly.
- *
- * @param TypoScriptFrontendController $frontendController
- * @param $timeOutTime
- */
- public function insertPageIncache(TypoScriptFrontendController $frontendController, $timeOutTime)
- {
- if (!$this->proxyProvider->isActive() || !$this->proxyProvider->shouldRequestBeMarkedAsCached($this->getRequest())) {
- return;
- }
- // cache the page URL that was called
- $url = (string)$this->getRequest()->getUri();
- $this->cache->set(md5($url), $url, $frontendController->getPageCacheTags(), $timeOutTime);
- }
-
- protected function getRequest(): ?ServerRequestInterface
- {
- return $GLOBALS['TYPO3_REQUEST'];
- }
-}
diff --git a/Classes/Listener/AfterCacheIsPersisted.php b/Classes/Listener/AfterCacheIsPersisted.php
index 2781c48..ea7af46 100644
--- a/Classes/Listener/AfterCacheIsPersisted.php
+++ b/Classes/Listener/AfterCacheIsPersisted.php
@@ -36,7 +36,7 @@ public function __invoke(AfterCachedPageIsPersistedEvent $event): void
if (!$this->proxyProvider->isActive()) {
return;
}
- $cacheTags = $event->getController()->getPageCacheTags();
+ $cacheTags = $event->getCacheData()['cacheTags'] ?? [];
$url = (string)$event->getRequest()->getUri();
$this->cache->set(md5($url), $url, $cacheTags, $event->getCacheLifetime());
}
diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml
index 49b6915..f8b3eb2 100644
--- a/Configuration/Services.yaml
+++ b/Configuration/Services.yaml
@@ -26,10 +26,6 @@ services:
identifier: 'b13-proxycachemanager-afterCacheIsPersisted'
arguments:
$cache: '@cache.tx_proxy'
- B13\Proxycachemanager\Hook\FrontendHook:
- public: true
- arguments:
- $cache: '@cache.tx_proxy'
B13\Proxycachemanager\ResourceStorageOperations\:
resource: '../Classes/ResourceStorageOperations/*'
diff --git a/Resources/Private/TemplatesV11/Management/Index.html b/Resources/Private/TemplatesV11/Management/Index.html
deleted file mode 100644
index c9a78b8..0000000
--- a/Resources/Private/TemplatesV11/Management/Index.html
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-