From 0d1f64d8d9d80d8b8654e1a673f39b016bb1f4d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Lochmu=CC=88ller?= Date: Sun, 31 Mar 2019 18:23:54 +0200 Subject: [PATCH] Feature - disable StaticFileCache by site configuration for TYPO3 V9 --- Classes/Cache/Rule/SiteCacheable.php | 40 +++++++++++++++++++ Classes/Configuration.php | 2 + .../SiteConfiguration/Overrides/sites.php | 14 +++++++ 3 files changed, 56 insertions(+) create mode 100755 Classes/Cache/Rule/SiteCacheable.php create mode 100644 Configuration/SiteConfiguration/Overrides/sites.php diff --git a/Classes/Cache/Rule/SiteCacheable.php b/Classes/Cache/Rule/SiteCacheable.php new file mode 100755 index 000000000000..c2e032b1cc25 --- /dev/null +++ b/Classes/Cache/Rule/SiteCacheable.php @@ -0,0 +1,40 @@ +getAttribute('site'); + if (!($site instanceof \TYPO3\CMS\Core\Site\Entity\Site)) { + return; + } + $config = $site->getConfiguration(); + if (isset($config['disableStaticFileCache']) && $config['disableStaticFileCache']) { + $explanation[__CLASS__] = 'static cache disabled on site configuration: ' . $site->getIdentifier(); + } + } +} diff --git a/Classes/Configuration.php b/Classes/Configuration.php index 55bd50ec922e..979aad7bb62e 100644 --- a/Classes/Configuration.php +++ b/Classes/Configuration.php @@ -20,6 +20,7 @@ use SFC\Staticfilecache\Cache\Rule\NoUserOrGroupSet; use SFC\Staticfilecache\Cache\Rule\NoWorkspacePreview; use SFC\Staticfilecache\Cache\Rule\PageCacheable; +use SFC\Staticfilecache\Cache\Rule\SiteCacheable; use SFC\Staticfilecache\Cache\Rule\StaticCacheable; use SFC\Staticfilecache\Cache\Rule\ValidDoktype; use SFC\Staticfilecache\Cache\Rule\ValidRequestMethod; @@ -112,6 +113,7 @@ public static function registerSlots() $ruleClasses = [ StaticCacheable::class, ValidUri::class, + SiteCacheable::class, ValidDoktype::class, NoWorkspacePreview::class, NoUserOrGroupSet::class, diff --git a/Configuration/SiteConfiguration/Overrides/sites.php b/Configuration/SiteConfiguration/Overrides/sites.php new file mode 100644 index 000000000000..ee8e0494c15a --- /dev/null +++ b/Configuration/SiteConfiguration/Overrides/sites.php @@ -0,0 +1,14 @@ + 'Disable StaticFileCache', + 'config' => [ + 'type' => 'check', + ], +]; + +$GLOBALS['SiteConfiguration']['site']['types']['0']['showitem'] = str_replace( + 'base,', + 'base, disableStaticFileCache, ', + $GLOBALS['SiteConfiguration']['site']['types']['0']['showitem'] +);