Commit 211c3a7b authored by Christian Kuhn's avatar Christian Kuhn
Browse files

[BUGFIX] Clear cache inconsistency in toolbar

With the simplification of the clear cache items in
toolbar the clearCacheSystem TYPO3_CONF_VARS was
rendered obsolete.
The patch removes last occurences in toolbar and
simplifies the visibility restrictions again: The
clear all toolbar item is now shown if user is admin
and the TSconfig option is not explictly disabling
the option for an admin, or a non-admin has the
TSconfig options.clearCache.all set to 1.

Change-Id: I5608baf2d4fe0c21dcc38f09fc17e550fcbfe8ff
Resolves: #75844
Releases: master
Reviewed-on: https://review.typo3.org/47835


Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Oliver Hader's avatarOliver Hader <oliver.hader@typo3.org>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent eb2ca5d2
......@@ -67,16 +67,12 @@ class ClearCacheToolbarItem implements ToolbarItemInterface
$this->optionValues[] = 'pages';
}
// Clearing of system cache (core cache, class cache etc)
// is only shown explicitly if activated for a BE-user (not activated for admins by default)
// or if the system runs in development mode (only for admins)
// or if $GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] is set (only for admins)
if ($backendUser->getTSConfigVal('options.clearCache.all')
|| (GeneralUtility::getApplicationContext()->isDevelopment() && $backendUser->isAdmin())
|| ((bool)$GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] === true && $backendUser->isAdmin())
) {
// Clearing of all caches is only shown if explicitly enabled via TSConfig
// or if BE-User is admin and the TSconfig explicitly disables the possibility for admins.
// This is useful for big production systems where admins accidentally could slow down the system.
if ($backendUser->getTSConfigVal('options.clearCache.all') || ($backendUser->isAdmin() && $backendUser->getTSConfigVal('options.clearCache.all') !== '0')) {
$this->cacheActions[] = array(
'id' => 'system',
'id' => 'all',
'title' => htmlspecialchars($languageService->sL('LLL:EXT:lang/locallang_core.xlf:flushAllCachesTitle2')),
'description' => htmlspecialchars($languageService->sL('LLL:EXT:lang/locallang_core.xlf:flushAllCachesDescription2')),
'href' => BackendUtility::getModuleUrl('tce_db', ['vC' => $backendUser->veriCode(), 'cacheCmd' => 'all']),
......
......@@ -7812,7 +7812,10 @@ class DataHandler
}
break;
case 'all':
if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.all')) {
// allow to clear all caches if the TS config option is enabled or the option is not explicitly
// disabled for admins (which could clear all caches by default). The latter option is useful
// for big production sites where it should be possible to restrict the cache clearing for some admins.
if ($this->BE_USER->getTSConfigVal('options.clearCache.all') || ($this->admin && $this->BE_USER->getTSConfigVal('options.clearCache.all') !== '0')) {
$this->getCacheManager()->flushCaches();
GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('cache_treelist')
......@@ -7826,11 +7829,9 @@ class DataHandler
case 'system':
GeneralUtility::deprecationLog(
'Calling clear_cacheCmd() with arguments \'temp_cached\' or \'system\', using'
. ' the ts config option \'options.clearCache.system\' or using'
. '\'$GLOBALS[\'TYPO3_CONF_VARS\'][\'SYS\'][\'clearCacheSystem\'] has been deprecated.'
. ' the TS config option \'options.clearCache.system\' has been deprecated.'
);
if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.system')
|| ((bool)$GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] === true && $this->admin)) {
if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.system')) {
$this->getCacheManager()->flushCachesInGroup('system');
}
break;
......
......@@ -104,7 +104,7 @@ return array(
'frontend' => \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class,
'backend' => \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class,
'options' => array(),
'groups' => array('pages', 'all')
'groups' => array('pages')
),
'cache_pages' => array(
'frontend' => \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class,
......@@ -112,7 +112,7 @@ return array(
'options' => array(
'compression' => true
),
'groups' => array('pages', 'all')
'groups' => array('pages')
),
'cache_pagesection' => array(
'frontend' => \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class,
......@@ -121,7 +121,7 @@ return array(
'compression' => true,
'defaultLifetime' => 2592000, // 30 days; set this to a lower value in case your cache gets too big
),
'groups' => array('pages', 'all')
'groups' => array('pages')
),
'cache_phpcode' => array(
'frontend' => \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend::class,
......@@ -143,7 +143,7 @@ return array(
'options' => array(
'defaultLifetime' => 2592000, // 30 days; set this to a lower value in case your cache gets too big
),
'groups' => array('pages', 'all')
'groups' => array('pages')
),
'cache_imagesizes' => array(
'frontend' => \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class,
......
......@@ -9,7 +9,7 @@ The following commands have been deprecated and should not be used anymore:
* Method :php:`DataHandler->clear_cacheCmd()` with arguments `system` and `temp_cached`
* ``userTSconfig`` setting ``options.clearCache.system``
* Option ``$TYPO3_CONF_VARS['SYS']['clearCacheSystem']``
* Option ``$TYPO3_CONF_VARS['SYS']['clearCacheSystem']`` has been removed
Impact
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment