Commit 791f3576 authored by Alexander Stehlik's avatar Alexander Stehlik Committed by Helmut Hummel
Browse files

[BUGFIX] Cache CategoryRegistry state together with TCA

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's avatarMarkus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: default avatarHelmut Hummel <helmut.hummel@typo3.org>
Tested-by: default avatarHelmut Hummel <helmut.hummel@typo3.org>
parent 3a7213c8
......@@ -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']));
}
/**
......
......@@ -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);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment