Commit da8841e2 authored by Benni Mack's avatar Benni Mack Committed by Susanne Moog
Browse files

[TASK] Deprecate BackendUtility::getHash/storeHash

The methods are only wrappers for the Caching framework, and come
from the time where the caching framework wasn't available.

Resolves: #83116
Releases: master
Change-Id: I6e3293f1bde654ee6548898742daa77d044d2107
Reviewed-on: https://review.typo3.org/54758


Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Susanne Moog's avatarSusanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog's avatarSusanne Moog <susanne.moog@typo3.org>
parent 5b9bf53b
......@@ -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,
......
......@@ -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;
......
......@@ -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;
}
......
.. 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
......@@ -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',
],
],
];
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