From a904a4fa02b1effa12a61b72af186e7fa8c3a41a Mon Sep 17 00:00:00 2001
From: Christian Kuhn <lolli@schwarzbu.ch>
Date: Thu, 14 Apr 2016 18:11:04 +0200
Subject: [PATCH] [TASK] Cleanup cache clearing

With change #75581 the backend toolbar cache handling the
"system" options are obsolete and can be deprecated.

Additionally, the label change is moved to an own label to
not clash with 7.6 and the now obsolete labels are deleted.

Change-Id: I666d73a97251beeddba78fba1940c0ea7fa29e58
Resolves: #75625
Related: #75581
Releases: master
Reviewed-on: https://review.typo3.org/47673
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Reviewed-by: Benjamin Kott <info@bk2k.info>
Tested-by: Benjamin Kott <info@bk2k.info>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
---
 .../ToolbarItems/ClearCacheToolbarItem.php    |  4 +--
 .../core/Classes/DataHandling/DataHandler.php |  7 +++--
 .../Configuration/DefaultConfiguration.php    |  1 -
 ...n-75625-DeprecatedCacheClearingOptions.rst | 31 +++++++++++++++++++
 .../Configuration/Context/CustomPreset.php    |  1 -
 .../Configuration/Context/DebugPreset.php     |  1 -
 .../Configuration/Context/LivePreset.php      |  1 -
 .../SilentConfigurationUpgradeService.php     |  4 ++-
 typo3/sysext/lang/locallang_core.xlf          | 18 ++---------
 9 files changed, 44 insertions(+), 24 deletions(-)
 create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Deprecation-75625-DeprecatedCacheClearingOptions.rst

diff --git a/typo3/sysext/backend/Classes/Backend/ToolbarItems/ClearCacheToolbarItem.php b/typo3/sysext/backend/Classes/Backend/ToolbarItems/ClearCacheToolbarItem.php
index 4faa057338ed..24da0fab5a02 100644
--- a/typo3/sysext/backend/Classes/Backend/ToolbarItems/ClearCacheToolbarItem.php
+++ b/typo3/sysext/backend/Classes/Backend/ToolbarItems/ClearCacheToolbarItem.php
@@ -77,8 +77,8 @@ class ClearCacheToolbarItem implements ToolbarItemInterface
         ) {
             $this->cacheActions[] = array(
                 'id' => 'system',
-                'title' => htmlspecialchars($languageService->sL('LLL:EXT:lang/locallang_core.xlf:flushSystemCachesTitle')),
-                'description' => htmlspecialchars($languageService->sL('LLL:EXT:lang/locallang_core.xlf:flushSystemCachesDescription')),
+                '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']),
                 'icon' => $this->iconFactory->getIcon('actions-system-cache-clear-impact-high', Icon::SIZE_SMALL)->render()
             );
diff --git a/typo3/sysext/core/Classes/DataHandling/DataHandler.php b/typo3/sysext/core/Classes/DataHandling/DataHandler.php
index 323f67e795e7..34cf327c0ce4 100644
--- a/typo3/sysext/core/Classes/DataHandling/DataHandler.php
+++ b/typo3/sysext/core/Classes/DataHandling/DataHandler.php
@@ -7812,8 +7812,6 @@ class DataHandler
                 break;
             case 'all':
                 if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.all')) {
-                    // Delete typo3temp/var/Cache manually as quick, straight and brutal approach here
-                    GeneralUtility::flushDirectory(PATH_site . 'typo3temp/var/Cache', true, true);
                     $this->getCacheManager()->flushCaches();
                     $this->databaseConnection->exec_TRUNCATEquery('cache_treelist');
                     // Delete Opcode Cache
@@ -7822,6 +7820,11 @@ class DataHandler
                 break;
             case 'temp_cached':
             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.'
+                );
                 if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.system')
                     || ((bool)$GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] === true && $this->admin)) {
                     $this->getCacheManager()->flushCachesInGroup('system');
diff --git a/typo3/sysext/core/Configuration/DefaultConfiguration.php b/typo3/sysext/core/Configuration/DefaultConfiguration.php
index 132a3d34fecf..2fd8b997a2da 100644
--- a/typo3/sysext/core/Configuration/DefaultConfiguration.php
+++ b/typo3/sysext/core/Configuration/DefaultConfiguration.php
@@ -277,7 +277,6 @@ return array(
         'livesearch' => array(),    // Array: keywords used for commands to search for specific tables
         'isInitialInstallationInProgress' => false,        // Boolean: If TRUE, the installation is 'in progress'. This value is handled within the install tool step installer internally.
         'isInitialDatabaseImportDone' => true,        // Boolean: If TRUE, the database import is finished. This value is handled within the install tool step installer internally.
-        'clearCacheSystem' => false,        // Boolean: If set, the toolbar menu entry for clearing system caches (core cache, class cache, etc.) is visible for admin users.
         'formEngine' => array(
             'nodeRegistry' => array(), // Array: Registry to add or overwrite FormEngine nodes. Main key is a timestamp of the date when an entry is added, sub keys type, priority and class are required. Class must implement TYPO3\CMS\Backend\Form\NodeInterface.
             'nodeResolver' => array(), // Array: Additional node resolver. Main key is a timestamp of the date when an entry is added, sub keys type, priority and class are required. Class must implement TYPO3\CMS\Backend\Form\NodeResolverInterface.
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-75625-DeprecatedCacheClearingOptions.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-75625-DeprecatedCacheClearingOptions.rst
new file mode 100644
index 000000000000..4738673f285b
--- /dev/null
+++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-75625-DeprecatedCacheClearingOptions.rst
@@ -0,0 +1,31 @@
+=======================================================
+Deprecation: #75625 - Deprecated cache clearing options
+=======================================================
+
+Description
+===========
+
+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']``
+
+
+Impact
+======
+
+Directly or indirectly using method ``clear_cacheCmd`` with these arguments will trigger a deprecation log entry.
+
+
+Affected Installations
+======================
+
+All installations with third party extensions using this method are affected.
+
+
+Migration
+=========
+
+If the group of system caches needs to be deleted explicitely, use :php:`flushCachesInGroup('system')`
+of ``CacheManager`` directly.
\ No newline at end of file
diff --git a/typo3/sysext/install/Classes/Configuration/Context/CustomPreset.php b/typo3/sysext/install/Classes/Configuration/Context/CustomPreset.php
index 6e6e34ef33c6..28a478a69aec 100644
--- a/typo3/sysext/install/Classes/Configuration/Context/CustomPreset.php
+++ b/typo3/sysext/install/Classes/Configuration/Context/CustomPreset.php
@@ -32,6 +32,5 @@ class CustomPreset extends Configuration\AbstractCustomPreset implements Configu
         'SYS/enableDeprecationLog' => '',
         'SYS/sqlDebug' => '',
         'SYS/systemLogLevel' => '',
-        'SYS/clearCacheSystem' => '',
     );
 }
diff --git a/typo3/sysext/install/Classes/Configuration/Context/DebugPreset.php b/typo3/sysext/install/Classes/Configuration/Context/DebugPreset.php
index a328859f2bca..97192f09eebe 100644
--- a/typo3/sysext/install/Classes/Configuration/Context/DebugPreset.php
+++ b/typo3/sysext/install/Classes/Configuration/Context/DebugPreset.php
@@ -44,7 +44,6 @@ class DebugPreset extends Configuration\AbstractPreset
         'SYS/systemLogLevel' => 0,
         // E_WARNING | E_RECOVERABLE_ERROR | E_DEPRECATED | E_USER_DEPRECATED
         'SYS/exceptionalErrors' => 28674,
-        'SYS/clearCacheSystem' => true,
     );
 
     /**
diff --git a/typo3/sysext/install/Classes/Configuration/Context/LivePreset.php b/typo3/sysext/install/Classes/Configuration/Context/LivePreset.php
index fe0c763317d6..5c5b7f5f1351 100644
--- a/typo3/sysext/install/Classes/Configuration/Context/LivePreset.php
+++ b/typo3/sysext/install/Classes/Configuration/Context/LivePreset.php
@@ -42,7 +42,6 @@ class LivePreset extends Configuration\AbstractPreset
         'SYS/enableDeprecationLog' => false,
         'SYS/sqlDebug' => 0,
         'SYS/systemLogLevel' => 2,
-        'SYS/clearCacheSystem' => false,
     );
 
     /**
diff --git a/typo3/sysext/install/Classes/Service/SilentConfigurationUpgradeService.php b/typo3/sysext/install/Classes/Service/SilentConfigurationUpgradeService.php
index cd6eb7ce7d0d..7368da2d9be7 100755
--- a/typo3/sysext/install/Classes/Service/SilentConfigurationUpgradeService.php
+++ b/typo3/sysext/install/Classes/Service/SilentConfigurationUpgradeService.php
@@ -96,7 +96,9 @@ class SilentConfigurationUpgradeService
         'SYS/curlTimeout',
         // #75355
         'BE/niceFlexFormXMLtags',
-        'BE/compactFlexFormXML'
+        'BE/compactFlexFormXML',
+        // #75625
+        'SYS/clearCacheSystem',
     ];
 
     public function __construct(ConfigurationManager $configurationManager = null)
diff --git a/typo3/sysext/lang/locallang_core.xlf b/typo3/sysext/lang/locallang_core.xlf
index 1a1650c71cdf..baafd2378645 100644
--- a/typo3/sysext/lang/locallang_core.xlf
+++ b/typo3/sysext/lang/locallang_core.xlf
@@ -863,23 +863,11 @@ Do you want to refresh it now?</source>
 			<trans-unit id="flushPageCachesDescription">
 				<source>Clear frontend and page-related caches.</source>
 			</trans-unit>
-			<trans-unit id="flushAllCachesTitle">
+			<trans-unit id="flushAllCachesTitle2">
 				<source>Flush all caches</source>
 			</trans-unit>
-			<trans-unit id="flushAllCachesDescription">
-				<source>Clear all caches, including frontend caches, and extension-specific caches. Compile-time caches / system caches that are needed for TYPO3 to run are not touched.</source>
-			</trans-unit>
-			<trans-unit id="flushGeneralCachesTitle">
-				<source>Flush general caches</source>
-			</trans-unit>
-			<trans-unit id="flushGeneralCachesDescription">
-				<source>Clear frontend and page-related caches, plus some backend-related caches.</source>
-			</trans-unit>
-			<trans-unit id="flushSystemCachesTitle">
-				<source>Flush all caches</source>
-			</trans-unit>
-			<trans-unit id="flushSystemCachesDescription">
-				<source>Clear all system-related caches, including the class loader, localization, extension configuration file caches and opcode caches. Rebuilding this cache may take some time.</source>
+			<trans-unit id="flushAllCachesDescription2">
+				<source>Clear all system-related caches, including localization, extension configuration, file caches and opcode caches. Rebuilding this cache may take some time.</source>
 			</trans-unit>
 			<trans-unit id="rm.adminFunctions">
 				<source>Admin functions</source>
-- 
GitLab