Skip to content
Merged
Show file tree
Hide file tree
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
28 changes: 4 additions & 24 deletions Classes/Cache/Backend/ReverseProxyCacheBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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()) {
Expand All @@ -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);
Expand All @@ -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 = [];
Expand Down
45 changes: 5 additions & 40 deletions Classes/Controller/ManagementController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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'));
}
Expand Down
62 changes: 0 additions & 62 deletions Classes/Hook/FrontendHook.php

This file was deleted.

2 changes: 1 addition & 1 deletion Classes/Listener/AfterCacheIsPersisted.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
4 changes: 0 additions & 4 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/*'
Expand Down
23 changes: 0 additions & 23 deletions Resources/Private/TemplatesV11/Management/Index.html

This file was deleted.

35 changes: 35 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
# Upgrade Instructions

v4 => v5

Proxycachemanager v5 drops support for TYPO3 v11 and v12. The minimum
supported version is now TYPO3 v13 LTS; v14 is fully supported.

## Removed

* `Classes/Hook/FrontendHook.php` — the v11-only `tslib/class.tslib_fe.php`
`insertPageIncache` hook. Cache writes are handled exclusively via the
`AfterCachedPageIsPersistedEvent` listener now.
* `Resources/Private/TemplatesV11/` — fallback Fluid template for the v11
backend module.
* `ext_tables.php` — v11-only `ExtensionUtility::registerModule()` call.
The module is registered through `Configuration/Backend/Modules.php` on
v12 and up.

## Changed

* `Classes/Listener/AfterCacheIsPersisted` no longer calls
`$event->getController()->getPageCacheTags()` — TYPO3 v14 dropped the
`controller` argument from `AfterCachedPageIsPersistedEvent`. Cache tags
are now read from `$event->getCacheData()['cacheTags']`, which TYPO3
populates in both v13 and v14.
* `Classes/Controller/ManagementController` no longer branches on the
TYPO3 major version. `\TYPO3\CMS\Core\Messaging\AbstractMessage::OK`,
`::WARNING`, `::ERROR` were removed in TYPO3 v14; the controller now
always uses `ContextualFeedbackSeverity::*` enum cases.

## Required platform

* PHP 8.2+
* TYPO3 13.4+ or 14.x

---

v3 => v4

Proxycachemanager v3 served for many years as a well thought out basis
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
}
},
"require": {
"php": "^8.1",
"typo3/cms-backend": "^11.5 || ^12.4 || ^13.4",
"typo3/cms-frontend": "^11.5 || ^12.4 || ^13.4"
"php": "^8.2",
"typo3/cms-backend": "^13.4 || ^14.0",
"typo3/cms-frontend": "^13.4 || ^14.0"
},
"require-dev": {
"saschaegerer/phpstan-typo3": "^1.10",
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
'author_company' => 'b13 GmbH',
'constraints' => [
'depends' => [
'typo3' => '11.5.0-13.4.99',
'typo3' => '13.4.0-14.99.99',
],
'conflicts' => [
],
Expand Down
5 changes: 0 additions & 5 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,3 @@
'groups' => ['pages', 'proxy'],
];
}

// Hook for adding any cacheable frontend URL to our proxy cache
// v11 only
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['insertPageIncache']['tx_proxycachemanager'] =
\B13\Proxycachemanager\Hook\FrontendHook::class;
27 changes: 0 additions & 27 deletions ext_tables.php

This file was deleted.