[TASK] Use "assets" cache for t3editor configuration 11/56811/4
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Wed, 25 Apr 2018 16:28:16 +0000 (18:28 +0200)
committerJigal van Hemert <jigal.van.hemert@typo3.org>
Wed, 2 May 2018 05:31:44 +0000 (07:31 +0200)
The t3editor cache is now stored in the `assets` cache, as `cache_core`
is discouraged for extensions.
As the cache only needs to store JavaScript-based configuration, this is
also a more appropriate cache.

Resolves: #84875
Releases: master
Change-Id: If77e6f91b4a540259fbd5b45a30ba441b110130c
Reviewed-on: https://review.typo3.org/56811
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Tested-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
typo3/sysext/t3editor/Classes/T3editor.php

index ba241eb..8faf3e0 100644 (file)
@@ -16,7 +16,7 @@ namespace TYPO3\CMS\T3editor;
  */
 
 use TYPO3\CMS\Core\Cache\CacheManager;
-use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend;
+use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Package\PackageManager;
 use TYPO3\CMS\Core\SingletonInterface;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -102,7 +102,7 @@ class T3editor implements SingletonInterface
 
         $cache = $this->getCache();
         $cacheIdentifier = $this->generateCacheIdentifier('T3editorConfiguration');
-        $configurationFromCache = $cache->requireOnce($cacheIdentifier);
+        $configurationFromCache = $cache->get($cacheIdentifier);
         if ($configurationFromCache !== false) {
             $this->configuration = $configurationFromCache;
         } else {
@@ -127,7 +127,7 @@ class T3editor implements SingletonInterface
                     }
                 }
             }
-            $cache->set($cacheIdentifier, 'return json_decode(\'' . json_encode($this->configuration) . '\', true);');
+            $cache->set($cacheIdentifier, $this->configuration);
         }
 
         return $this->configuration;
@@ -147,8 +147,8 @@ class T3editor implements SingletonInterface
      * @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
      * @throws \InvalidArgumentException
      */
-    protected function getCache(): PhpFrontend
+    protected function getCache(): FrontendInterface
     {
-        return GeneralUtility::makeInstance(CacheManager::class)->getCache('cache_core');
+        return GeneralUtility::makeInstance(CacheManager::class)->getCache('assets');
     }
 }