[BUGFIX] Cache CategoryRegistry state together with TCA 70/43070/4
authorAlexander Stehlik <alexander.stehlik@gmail.com>
Wed, 2 Sep 2015 21:14:28 +0000 (23:14 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Sun, 6 Sep 2015 17:06:28 +0000 (19:06 +0200)
The CategoryRegistry is stored together with the final TCA in
the cache.

This is needed because the registry is filled during the initial
build of the TCA and not when the TCA is loaded from the cache.

Resolves: #67881
Releases: master, 6.2
Change-Id: Ic7f341a1710cafbc1a1ea150e003d3d7a7b9c458
Reviewed-on: http://review.typo3.org/43070
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Tested-by: Helmut Hummel <helmut.hummel@typo3.org>
typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php
typo3/sysext/core/Tests/Unit/Utility/ExtensionManagementUtilityTest.php

index 08ad5fa..5c9333f 100644 (file)
@@ -1629,7 +1629,9 @@ tt_content.' . $key . $prefix . ' {
                        $codeCache = static::getCacheManager()->getCache('cache_core');
                        if ($codeCache->has($cacheIdentifier)) {
                                // substr is necessary, because the php frontend wraps php code around the cache value
-                               $GLOBALS['TCA'] = unserialize(substr($codeCache->get($cacheIdentifier), 6, -2));
+                               $cacheData = unserialize(substr($codeCache->get($cacheIdentifier), 6, -2));
+                               $GLOBALS['TCA'] = $cacheData['tca'];
+                               GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Category\\CategoryRegistry', $cacheData['categoryRegistry']);
                        } else {
                                static::buildBaseTcaFromSingleFiles();
                                static::createBaseTcaCacheFile();
@@ -1723,7 +1725,7 @@ tt_content.' . $key . $prefix . ' {
        static protected function createBaseTcaCacheFile() {
                /** @var $codeCache \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend */
                $codeCache = self::getCacheManager()->getCache('cache_core');
-               $codeCache->set(static::getBaseTcaCacheIdentifier(), serialize($GLOBALS['TCA']));
+               $codeCache->set(static::getBaseTcaCacheIdentifier(), serialize(array('tca' => $GLOBALS['TCA'], 'categoryRegistry' => \TYPO3\CMS\Core\Category\CategoryRegistry::getInstance())));
        }
 
        /**
@@ -1732,7 +1734,7 @@ tt_content.' . $key . $prefix . ' {
         * @return string
         */
        static protected function getBaseTcaCacheIdentifier() {
-               return 'tca_base_' . sha1(TYPO3_version . PATH_site . 'tca' . serialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['runtimeActivatedPackages']));
+               return 'tca_base_' . sha1(TYPO3_version . PATH_site . 'tca_with_category_registry' . serialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['runtimeActivatedPackages']));
        }
 
        /**
index 723fca0..57d4bbf 100644 (file)
@@ -1027,7 +1027,7 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                $mockCacheManager->expects($this->any())->method('getCache')->will($this->returnValue($mockCache));
                ExtensionManagementUtilityAccessibleProxy::setCacheManager($mockCacheManager);
                $mockCache->expects($this->any())->method('has')->will($this->returnValue(TRUE));
-               $mockCache->expects($this->once())->method('get');
+               $mockCache->expects($this->once())->method('get')->willReturn('<?php ' . serialize(array('tca' => array(), 'categoryRegistry' => \TYPO3\CMS\Core\Category\CategoryRegistry::getInstance())) . '?>');
                ExtensionManagementUtilityAccessibleProxy::loadBaseTca(TRUE);
        }