Bug #53370
closed
Cache getPagesTSconfig per ID and rootline
Added by Jo Hasenau over 10 years ago.
Updated over 6 years ago.
Description
During the discussion of #53368 the idea came up to improve the behaviour of \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig. If a proper memory cache would be used there, the whole parsing would be done only once per request for a certain page ID and rootline.
static public function getPagesTSconfig($id, $rootLine = '', $returnPartArray = 0) {
$id = intval($id);
if (!is_array($rootLine)) {
$rootLine = self::BEgetRootLine($id, '', TRUE);
}
// Order correctly
ksort($rootLine);
$TSdataArray = array();
// Setting default configuration
$TSdataArray['defaultPageTSconfig'] = $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'];
foreach ($rootLine as $k => $v) {
$TSdataArray['uid_' . $v['uid']] = $v['TSconfig'];
}
$TSdataArray = TypoScriptParser::checkIncludeLines_array($TSdataArray);
if ($returnPartArray) {
return $TSdataArray;
}
// Parsing the page TS-Config
$pageTS = implode(LF . '[GLOBAL]' . LF, $TSdataArray);
/* @var $parseObj \TYPO3\CMS\Backend\Configuration\TsConfigParser */
$parseObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Configuration\\TsConfigParser');
$res = $parseObj->parseTSconfig($pageTS, 'PAGES', $id, $rootLine);
if ($res) {
$TSconfig = $res['TSconfig'];
}
// Get User TSconfig overlay
$userTSconfig = $GLOBALS['BE_USER']->userTS['page.'];
if (is_array($userTSconfig)) {
$TSconfig = GeneralUtility::array_merge_recursive_overrule($TSconfig, $userTSconfig);
}
return $TSconfig;
}
While parseTSconfig already should make use of a cache, which is not working properly at the moment, we could still improve this method by creating TSconfig only once per request. This does not have to make use of the fully fledged caching framework but could use a variable to return it early.
This way we could get rid of having to do array_merge_recursive_overrule umpteen times during a single request.
- Subject changed from Cahe getPagesTSconfig per ID and rootline to Cache getPagesTSconfig per ID and rootline
- Status changed from New to Resolved
- Status changed from Resolved to Closed
Also available in: Atom
PDF