[TASK] Deprecate BackendUtility::getHash/storeHash 58/54758/4
authorBenni Mack <benni@typo3.org>
Fri, 24 Nov 2017 23:07:57 +0000 (00:07 +0100)
committerSusanne Moog <susanne.moog@typo3.org>
Mon, 27 Nov 2017 20:31:28 +0000 (21:31 +0100)
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: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
typo3/sysext/backend/Classes/Configuration/TsConfigParser.php
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php
typo3/sysext/core/Documentation/Changelog/master/Deprecation-83116-CachingFrameworkWrapperMethodsInBackendUtility.rst [new file with mode: 0644]
typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php

index 3ca7f85..8c1d724 100644 (file)
@@ -14,7 +14,8 @@ namespace TYPO3\CMS\Backend\Configuration;
  * The TYPO3 project - inspiring people to share!
  */
 
  * 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
 
 /**
  * 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);
         $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];
         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);
                 ];
             } else {
                 $shash = md5($checkMD5 . $hash);
-                $cachedSpec = BackendUtility::getHash($shash);
+                $cachedSpec = $cache->get($shash);
                 if (is_array($cachedSpec)) {
                     $storedData = $cachedSpec;
                     $res = [
                 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);
                     ];
                 } else {
                     $storeData = $this->parseWithConditions($TStext);
-                    BackendUtility::storeHash($shash, $storeData, $type . '_TSconfig');
                     $res = [
                         'TSconfig' => $storeData['TSconfig'],
                         'cached' => 0,
                         'hash' => $shash
                     ];
                     $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));
                 }
             }
         } 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,
             $res = [
                 'TSconfig' => $storeData['TSconfig'],
                 'cached' => 0,
index c384d8a..7e41715 100644 (file)
@@ -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!
      * @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)
     {
      */
     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);
     }
         $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
      *
      * @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)
     {
      */
     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;
         $cacheManager = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class);
         $cacheEntry = $cacheManager->getCache('cache_hash')->get($hash);
         $hashContent = null;
index 543dd28..ad74bda 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Core\Authentication;
  */
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
  */
 
 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;
 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);
             } 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;
                 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;
                 }
                     // 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 (file)
index 0000000..f681ffa
--- /dev/null
@@ -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
index 5324b3b..f6e95eb 100644 (file)
@@ -512,4 +512,18 @@ return [
             'Deprecation-83083-GeneralUtilityllXmlAutoFileName.rst',
         ],
     ],
             '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',
+        ],
+    ],
 ];
 ];