[TASK] Do not mis-use sys_page for using cache_hash in ExtDirectApi 14/52214/2
authorBenni Mack <benni@typo3.org>
Tue, 28 Mar 2017 11:14:38 +0000 (13:14 +0200)
committerSusanne Moog <susanne.moog@typo3.org>
Tue, 28 Mar 2017 14:16:37 +0000 (16:16 +0200)
The ExtDirectApi simply calls PageRepository to store data in the "cache_hash"
cache. This can be simplified by just using the Caching Framework directly
without depending on a EXT:frontend class in a EXT:core class.

Resolves: #80517
Releases: master
Change-Id: I77825bf71264621fb984b39f79009baf71cfdec3
Reviewed-on: https://review.typo3.org/52214
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Thomas Hohn <thomas@hohn.dk>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
typo3/sysext/core/Classes/ExtDirect/ExtDirectApi.php

index f77af5b..14c481a 100644 (file)
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Core\ExtDirect;
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
 use TYPO3\CMS\Backend\Routing\UriBuilder;
+use TYPO3\CMS\Core\Cache\CacheManager;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -159,14 +160,16 @@ class ExtDirectApi
     {
         $noCache = (bool)GeneralUtility::_GET('no_cache');
         // Look up into the cache
-        $cacheIdentifier = 'ExtDirectApi';
-        $cacheHash = md5($cacheIdentifier . implode(',', $filterNamespaces) . GeneralUtility::getIndpEnv('TYPO3_SSL') . serialize($this->settings) . TYPO3_MODE . GeneralUtility::getIndpEnv('HTTP_HOST'));
+        $cacheTag = 'ExtDirectApi';
+        $cacheIdentifier = md5($cacheTag . implode(',', $filterNamespaces) . GeneralUtility::getIndpEnv('TYPO3_SSL') . serialize($this->settings) . TYPO3_MODE . GeneralUtility::getIndpEnv('HTTP_HOST'));
         // With no_cache always generate the javascript content
         // Generate the javascript content if it wasn't found inside the cache and cache it!
-        if ($noCache || !is_array(($javascriptNamespaces = \TYPO3\CMS\Frontend\Page\PageRepository::getHash($cacheHash)))) {
+        /** @var \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache */
+        $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('cache_hash');
+        if ($noCache || !is_array(($javascriptNamespaces = $cache->get($cacheIdentifier)))) {
             $javascriptNamespaces = $this->generateAPI($filterNamespaces);
             if (!empty($javascriptNamespaces)) {
-                \TYPO3\CMS\Frontend\Page\PageRepository::storeHash($cacheHash, $javascriptNamespaces, $cacheIdentifier);
+                $cache->set($cacheIdentifier, $javascriptNamespaces, [$cacheTag]);
             }
         }
         return $javascriptNamespaces;