diff --git a/typo3/sysext/backend/Classes/Configuration/TsConfigParser.php b/typo3/sysext/backend/Classes/Configuration/TsConfigParser.php index 3ca7f859ce193f5f930edd4fdc6add78373d29e7..8c1d72461b227ad368c79b7ae9563bc7510bd040 100644 --- a/typo3/sysext/backend/Classes/Configuration/TsConfigParser.php +++ b/typo3/sysext/backend/Classes/Configuration/TsConfigParser.php @@ -14,7 +14,8 @@ namespace TYPO3\CMS\Backend\Configuration; * The TYPO3 project - inspiring people to share! */ -use TYPO3\CMS\Backend\Utility\BackendUtility; +use TYPO3\CMS\Core\Cache\CacheManager; +use TYPO3\CMS\Core\Utility\GeneralUtility; /** * A TS-Config parsing class which performs condition evaluation @@ -53,7 +54,9 @@ class TsConfigParser extends \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser $this->id = $id; $this->rootLine = $rootLine; $hash = md5($type . ':' . $TStext); - $cachedContent = BackendUtility::getHash($hash); + + $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('cache_hash'); + $cachedContent = $cache->get($hash); if (is_array($cachedContent)) { $storedData = $cachedContent[0]; $storedMD5 = $cachedContent[1]; @@ -68,7 +71,7 @@ class TsConfigParser extends \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser ]; } else { $shash = md5($checkMD5 . $hash); - $cachedSpec = BackendUtility::getHash($shash); + $cachedSpec = $cache->get($shash); if (is_array($cachedSpec)) { $storedData = $cachedSpec; $res = [ @@ -78,18 +81,18 @@ class TsConfigParser extends \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser ]; } else { $storeData = $this->parseWithConditions($TStext); - BackendUtility::storeHash($shash, $storeData, $type . '_TSconfig'); $res = [ 'TSconfig' => $storeData['TSconfig'], 'cached' => 0, 'hash' => $shash ]; + $cache->set($shash, $storeData, ['ident_' . $type . '_TSconfig'], 0); } } } else { $storeData = $this->parseWithConditions($TStext); $md5 = md5(serialize($storeData)); - BackendUtility::storeHash($hash, [$storeData, $md5], $type . '_TSconfig'); + $cache->set($hash, [$storeData, $md5], ['ident_' . $type . '_TSconfig'], 0); $res = [ 'TSconfig' => $storeData['TSconfig'], 'cached' => 0, diff --git a/typo3/sysext/backend/Classes/Utility/BackendUtility.php b/typo3/sysext/backend/Classes/Utility/BackendUtility.php index c384d8a9eaacfdbafe72d0aed5e66acd08a10d29..7e417151540c2911edcc0e88f14df2ff86d5af9f 100644 --- a/typo3/sysext/backend/Classes/Utility/BackendUtility.php +++ b/typo3/sysext/backend/Classes/Utility/BackendUtility.php @@ -781,10 +781,11 @@ class BackendUtility * @param string $hash 32 bit hash string (eg. a md5 hash of a serialized array identifying the data being stored) * @param mixed $data The data to store * @param string $ident $ident is just a textual identification in order to inform about the content! + * @deprecated since TYPO3 v9, will be removed in TYPO3 v10, use the Caching Framework directly */ public static function storeHash($hash, $data, $ident) { - /** @var CacheManager $cacheManager */ + trigger_error('This method will be removed in TYPO3 v10.0, use the Caching Framework directly.', E_USER_DEPRECATED); $cacheManager = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class); $cacheManager->getCache('cache_hash')->set($hash, $data, ['ident_' . $ident], 0); } @@ -795,10 +796,11 @@ class BackendUtility * * @param string $hash The hash-string which was used to store the data value * @return mixed The "data" from the cache + * @deprecated since TYPO3 v9, will be removed in TYPO3 v10, use the Caching Framework directly */ public static function getHash($hash) { - /** @var CacheManager $cacheManager */ + trigger_error('This method will be removed in TYPO3 v10.0, use the Caching Framework directly.', E_USER_DEPRECATED); $cacheManager = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class); $cacheEntry = $cacheManager->getCache('cache_hash')->get($hash); $hashContent = null; diff --git a/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php b/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php index 543dd28c4d16a63ba3e89b9b7809e1ef6d6b1f27..ad74bda5b88c60029ff4b8be726575537e43a1ac 100644 --- a/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php +++ b/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php @@ -15,6 +15,7 @@ namespace TYPO3\CMS\Core\Authentication; */ use TYPO3\CMS\Backend\Utility\BackendUtility; +use TYPO3\CMS\Core\Cache\CacheManager; use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder; @@ -1370,14 +1371,15 @@ class BackendUserAuthentication extends AbstractUserAuthentication } else { // Parsing the user TSconfig (or getting from cache) $hash = md5('userTS:' . $this->userTS_text); - $cachedContent = BackendUtility::getHash($hash); + $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('cache_hash'); + $cachedContent = $cache->get($hash); if (is_array($cachedContent) && !$this->userTS_dontGetCached) { $this->userTS = $cachedContent; } else { $parseObj = GeneralUtility::makeInstance(\TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::class); $parseObj->parse($this->userTS_text); $this->userTS = $parseObj->setup; - BackendUtility::storeHash($hash, $this->userTS, 'BE_USER_TSconfig'); + $cache->set($hash, $this->userTS, ['ident_BE_USER_TSconfig'], 0); // Update UC: $this->userTSUpdated = true; } diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-83116-CachingFrameworkWrapperMethodsInBackendUtility.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-83116-CachingFrameworkWrapperMethodsInBackendUtility.rst new file mode 100644 index 0000000000000000000000000000000000000000..f681ffa136ec8a4c843e4c359b40355153b104eb --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-83116-CachingFrameworkWrapperMethodsInBackendUtility.rst @@ -0,0 +1,33 @@ +.. include:: ../../Includes.txt + +========================================================================= +Deprecation: #83116 - Caching framework wrapper methods in BackendUtility +========================================================================= + +See :issue:`83116` + +Description +=========== + +The methods :php:``BackendUtility::getHash()`` and :php:``BackendUtility::storeHash()`` have been marked as +deprecated. + + +Impact +====== + +Calling the methods will trigger a deprecation warning. + + +Affected Installations +====================== + +Any extension using the methods in custom PHP code. + + +Migration +========= + +Use the Caching Framework directly, as the methods now only act as wrapper methods. + +.. index:: PHP-API, FullyScanned \ No newline at end of file diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php index 5324b3bd0fcd8ef06813337257b398ca3bf8114b..f6e95ebba245abf1a074c3ba0298ce3554d967b8 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php @@ -512,4 +512,18 @@ return [ 'Deprecation-83083-GeneralUtilityllXmlAutoFileName.rst', ], ], + 'TYPO3\CMS\Backend\Utility\BackendUtility::getHash' => [ + 'numberOfMandatoryArguments' => 1, + 'maximumNumberOfArguments' => 1, + 'restFiles' => [ + 'Deprecation-83116-CachingFrameworkWrapperMethodsInBackendUtility.rst', + ], + ], + 'TYPO3\CMS\Backend\Utility\BackendUtility::storeHash' => [ + 'numberOfMandatoryArguments' => 3, + 'maximumNumberOfArguments' => 3, + 'restFiles' => [ + 'Deprecation-83116-CachingFrameworkWrapperMethodsInBackendUtility.rst', + ], + ], ];