Skip to content

Commit

Permalink
[BUGFIX] Write caches correctly in DynamicFlexForm (FluidTYPO3#1285)
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricziel authored and NamelessCoder committed Jan 16, 2017
1 parent c43feff commit 6677a22
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions Classes/Backend/DynamicFlexForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ public function getDataStructureIdentifierPreProcess(array $tca, $tableName, $fi
if ($form->getOption(Form::OPTION_STATIC)) {
$identifier['staticIdentity'] = $formId;
$cache = $this->getCache();
if ($cache->has('datatructure-' . $formId)) {
static::$generatedDataSources[$formId] = $cache->get('datastructure-' . $formId);
$cacheKey = $this->calculateFormCacheKey($formId);
if ($cache->has($cacheKey)) {
static::$generatedDataSources[$formId] = $cache->get($cacheKey);
} else {
// This provider has requested static DS caching; stop attempting
// to process any other DS and cache this DS as final result:
Expand All @@ -132,7 +133,7 @@ public function getDataStructureIdentifierPreProcess(array $tca, $tableName, $fi
return $identifier;
}
$provider->postProcessDataStructure($record, $dataStructArray, $identifier);
$cache->set('datastructure-' . $formId, $dataStructArray);
$cache->set($cacheKey, $dataStructArray);
static::$generatedDataSources[$formId] = $dataStructArray;
}
return $identifier;
Expand Down Expand Up @@ -233,8 +234,9 @@ public function getFlexFormDS_postProcessDS(&$dataStructArray, $conf, &$row, $ta
$formId = $form->getId();
if ($form->getOption(Form::OPTION_STATIC)) {
$cache = $this->getCache();
if ($cache->has('datatructure-' . $formId)) {
$dataStructArray = $cache->get('datastructure-' . $formId);
$cacheKey = $this->calculateFormCacheKey($formId);
if ($cache->has($cacheKey)) {
$dataStructArray = $cache->get($cacheKey);
return;
}
// This provider has requested static DS caching; stop attempting
Expand All @@ -244,7 +246,7 @@ public function getFlexFormDS_postProcessDS(&$dataStructArray, $conf, &$row, $ta
return $identifier;
}
$provider->postProcessDataStructure($row, $dataStructArray, $conf);
$cache->set('datastructure-' . $formId, $dataStructArray);
$cache->set($cacheKey, $dataStructArray);
return $dataStructArray;
} else {
$provider->postProcessDataStructure($row, $dataStructArray, $conf);
Expand Down Expand Up @@ -323,4 +325,14 @@ protected function getCache()
{
return GeneralUtility::makeInstance(CacheManager::class)->getCache('flux');
}

/**
* @param string $formId
*
* @return string
*/
private function calculateFormCacheKey($formId): string
{
return 'datastructure-'.$formId;
}
}

0 comments on commit 6677a22

Please sign in to comment.