Issue Bug Closed

#63674High memory consumption in BackendUtility->explodeSoftRefParserList while bulk inserting

Stephan Großberndt 12/08/14, 15:53 updated 10/02/18, 11:48

Description

Due to improper checking for an empty value BackendUtility->explodeSoftRefParserList multiple trimExplodes per record are executed

static public function explodeSoftRefParserList($parserList) {
    // Looking for global parsers:
    if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['softRefParser_GL'])) {
        $parserList = implode(',', array_keys($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['softRefParser_GL'])) . ',' . $parserList;
    }
    // Return immediately if list is blank:
    if (!strlen($parserList)) {
        return FALSE;
    }

Using only is_array when looking for global parsers and appending ‘,’ . $parserList leads to $parserList = ‘,’ which does not result in an early return but a full parse.

static public function explodeSoftRefParserList($parserList) {
    // Looking for global parsers:
    if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['softRefParser_GL']) && count($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['softRefParser_GL']) > 0) {
        $parserList = implode(',', array_keys($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['softRefParser_GL'])) . ',' . $parserList;
    }
    // Return immediately if list is blank:
    if (!strlen($parserList)) {
        return FALSE;
    }

For bulk inserting of 6500 records:

  • 1 sec faster
  • memory_usage of explodeSoftRefParserList down by 4.5MB

Reviews 2