[BUGFIX] Clear cache inconsistency in toolbar 35/47835/6
authorChristian Kuhn <lolli@schwarzbu.ch>
Thu, 21 Apr 2016 12:13:07 +0000 (14:13 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 3 May 2016 09:41:58 +0000 (11:41 +0200)
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 <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Backend/ToolbarItems/ClearCacheToolbarItem.php
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/core/Configuration/DefaultConfiguration.php
typo3/sysext/core/Documentation/Changelog/master/Deprecation-75625-DeprecatedCacheClearingOptions.rst

index 24da0fa..cc0afd7 100644 (file)
@@ -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']),
index ccba87f..b811a96 100644 (file)
@@ -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;
index e723eda..ea2057f 100644 (file)
@@ -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,
index 4738673..60df0ff 100644 (file)
@@ -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