Bug #53370

Cache getPagesTSconfig per ID and rootline

Added by Jo Hasenau over 1 year ago. Updated 8 months ago.

Status:Resolved Start date:2013-11-06
Priority:Must have Due date:
Assigned To:Jigal van Hemert % Done:

0%

Category:Performance Spent time: -
Target version:6.2.0
TYPO3 Version:6.2 Is Regression:No
PHP Version:5.4 Sprint Focus:
Complexity:

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.


Related issues

related to Core - Bug #53368: Use getPagesTSconfig($tscPID) only once per ID Resolved 2013-11-06
related to Core - Bug #63629: High memory consumption in BackendUtility::getPagesTSconf... Resolved 2014-12-06

History

#1 Updated by Jo Hasenau over 1 year ago

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.

#2 Updated by Georg Ringer over 1 year ago

  • Subject changed from Cahe getPagesTSconfig per ID and rootline to Cache getPagesTSconfig per ID and rootline

#3 Updated by Georg Ringer 8 months ago

  • Status changed from New to Resolved

resolved with #63629

Also available in: Atom PDF