[BUGFIX] Cache CategoryRegistry state together with TCA 45/40845/7
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 14:59:19 +0000 (16:59 +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/40845
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: 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 be81fb8..ca2dd18 100644 (file)
@@ -1657,7 +1657,9 @@ tt_content.' . $key . $suffix . ' {
                        $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(CategoryRegistry::class, $cacheData['categoryRegistry']);
                        } else {
                                static::buildBaseTcaFromSingleFiles();
                                static::createBaseTcaCacheFile();
@@ -1764,7 +1766,7 @@ tt_content.' . $key . $suffix . ' {
        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' => CategoryRegistry::getInstance())));
        }
 
        /**
@@ -1773,7 +1775,7 @@ tt_content.' . $key . $suffix . ' {
         * @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 35b28b0..fcfe2fa 100644 (file)
@@ -1396,7 +1396,7 @@ class ExtensionManagementUtilityTest extends 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' => CategoryRegistry::getInstance())) . '?>');
                ExtensionManagementUtilityAccessibleProxy::loadBaseTca(TRUE);
        }