[TASK] Replace TCA cache with serialized array 92/25492/6
authorThomas Maroschik <tmaroschik@dfau.de>
Mon, 18 Nov 2013 21:59:11 +0000 (22:59 +0100)
committerThomas Maroschik <tmaroschik@dfau.de>
Thu, 21 Nov 2013 09:55:05 +0000 (10:55 +0100)
The TCA isn't stored as php array anymore,
but instead as serialized array string. Unserialize
seems to be much faster in this regard although
opcode caches have been tested.

Resolves: #53747
Releases: 6.2
Change-Id: I540cae2ecee0ef09635ceff0b91b7a940dae01f7
Reviewed-on: https://review.typo3.org/25492
Reviewed-by: Alexander Opitz
Tested-by: Alexander Opitz
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Thomas Maroschik
Tested-by: Thomas Maroschik
typo3/sysext/core/Classes/Core/Bootstrap.php
typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php
typo3/sysext/core/Tests/Unit/Core/BootstrapTest.php
typo3/sysext/core/Tests/Unit/Utility/ExtensionManagementUtilityTest.php

index 72c438b..58c5a87 100644 (file)
@@ -914,11 +914,11 @@ class Bootstrap {
                /** @var $codeCache \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend */
                $codeCache = $GLOBALS['typo3CacheManager']->getCache('cache_core');
                if ($codeCache->has($cacheIdentifier)) {
-                       $codeCache->requireOnce($cacheIdentifier);
+                       // substr is necessary, because the php frontend wraps php code around the cache value
+                       $GLOBALS['TCA'] = unserialize(substr($codeCache->get($cacheIdentifier), 6, -2));
                } else {
                        $this->loadExtensionTables(TRUE);
-                       $phpCodeToCache = '$GLOBALS[\'TCA\'] = ' . var_export($GLOBALS['TCA'], TRUE) . ';';
-                       $codeCache->set($cacheIdentifier, $phpCodeToCache);
+                       $codeCache->set($cacheIdentifier, serialize($GLOBALS['TCA']));
                }
                return $this;
        }
index f0a0ed3..a860db6 100644 (file)
@@ -1515,7 +1515,8 @@ tt_content.' . $key . $prefix . ' {
                        /** @var $codeCache \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend */
                        $codeCache = $GLOBALS['typo3CacheManager']->getCache('cache_core');
                        if ($codeCache->has($cacheIdentifier)) {
-                               $codeCache->requireOnce($cacheIdentifier);
+                               // substr is necessary, because the php frontend wraps php code around the cache value
+                               $GLOBALS['TCA'] = unserialize(substr($codeCache->get($cacheIdentifier), 6, -2));
                        } else {
                                self::buildBaseTcaFromSingleFiles();
                                self::createBaseTcaCacheFile();
@@ -1565,10 +1566,9 @@ tt_content.' . $key . $prefix . ' {
         * @return void
         */
        static protected function createBaseTcaCacheFile() {
-               $phpCodeToCache = '$GLOBALS[\'TCA\'] = ' . var_export($GLOBALS['TCA'], TRUE) . ';';
                /** @var $codeCache \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend */
                $codeCache = $GLOBALS['typo3CacheManager']->getCache('cache_core');
-               $codeCache->set(static::getBaseTcaCacheIdentifier(), $phpCodeToCache);
+               $codeCache->set(static::getBaseTcaCacheIdentifier(), serialize($GLOBALS['TCA']));
        }
 
        /**
index dc226f4..d5c70e3 100644 (file)
@@ -68,7 +68,7 @@ class BootstrapTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                        ->will($this->returnValue(TRUE));
                $mockCache
                        ->expects($this->once())
-                       ->method('requireOnce');
+                       ->method('get');
                $bootstrapInstance->loadCachedTca();
        }
 
index f70562d..d1b6d22 100644 (file)
@@ -845,7 +845,7 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                $GLOBALS['typo3CacheManager'] = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array('getCache'));
                $GLOBALS['typo3CacheManager']->expects($this->any())->method('getCache')->will($this->returnValue($mockCache));
                $mockCache->expects($this->any())->method('has')->will($this->returnValue(TRUE));
-               $mockCache->expects($this->once())->method('requireOnce');
+               $mockCache->expects($this->once())->method('get');
                ExtensionManagementUtility::loadBaseTca(TRUE);
        }