Skip to content

Commit

Permalink
Merge pull request #4 from netlogix/bugfix/expose-cache-lifetime
Browse files Browse the repository at this point in the history
  • Loading branch information
saschanowak authored Mar 7, 2023
2 parents ec23905 + dadca6d commit 83dbf04
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Classes/Service/CacheTagService.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CacheTagService extends AbstractService implements SingletonInterface
protected array $environments = [
[
self::ENVIRONMENT_TAGS => [],
self::ENVIRONMENT_LIFETIME => null,
self::ENVIRONMENT_LIFETIME => 0,
],
];

Expand Down Expand Up @@ -263,7 +263,7 @@ protected function getObjectIdentificationHelpers(): array
public function exposeCacheLifetime(array $params, TypoScriptFrontendController $tsfe)
{
$environmentLifetime = $this->getEnvironmentLifetime();
if (!$environmentLifetime) {
if ($environmentLifetime === 0) {
return $params['cacheTimeout'];
} else {
return min($params['cacheTimeout'], $environmentLifetime);
Expand Down Expand Up @@ -342,6 +342,9 @@ public function addPageCacheTags($objectOrCacheTag)

public function decreaseEnvironmentLifetime(int $lifetime)
{
if ($lifetime === 0) {
return;
}
foreach ($this->environments as &$environment) {
if ($environment[self::ENVIRONMENT_LIFETIME] === 0 || ($environment[self::ENVIRONMENT_LIFETIME] > $lifetime)) {
$environment[self::ENVIRONMENT_LIFETIME] = $lifetime;
Expand Down
1 change: 1 addition & 0 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
call_user_func(function () {
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['createHashBase'][] = \Netlogix\Nxcachetags\Service\UserToHashBaseService::class . '->createHashBase';
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc'][] = \Netlogix\Nxcachetags\Hooks\DataHandler::class . '->clearCachePostProc';
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['get_cache_timeout'][] = \Netlogix\Nxcachetags\Service\CacheTagService::class . '->exposeCacheLifetime';

if (!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['nxcachetags_cacheviewhelper'])) {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['nxcachetags_cacheviewhelper'] = [
Expand Down

0 comments on commit 83dbf04

Please sign in to comment.