Issue Bug Closed

#63745date/datetime checks in DataHandler->checkValue_input lead to high memory use while bulk inserting

Stephan Großberndt 12/10/14, 17:45 updated 10/02/18, 11:48

Description

$dateTimeFormats are fetched for every input field (altough not needed) and the expensive GeneralUtility::inList-check for date,datetime-fields is executed twice:

public function checkValueForInput($res, $value, $tcaFieldConf, $table, $id, $realPid, $field = '') {
    // Handle native date/time fields
    $dateTimeFormats = $GLOBALS['TYPO3_DB']->getDateTimeFormats($table);
    if (isset($tcaFieldConf['dbType']) && GeneralUtility::inList('date,datetime', $tcaFieldConf['dbType'])) {
        // Convert the date/time into a timestamp for the sake of the checks
        $emptyValue = $dateTimeFormats[$tcaFieldConf['dbType']]['empty'];
        $format = $dateTimeFormats[$tcaFieldConf['dbType']]['format'];
        // At this point in the processing, the timestamps are still based on UTC
        $timeZone = new \DateTimeZone('UTC');
        $dateTime = \DateTime::createFromFormat('!' . $format, $value, $timeZone);
        $value = $value === $emptyValue ? 0 : $dateTime->getTimestamp();
    }

    [...]

    // Handle native date/time fields
    if (isset($tcaFieldConf['dbType']) && GeneralUtility::inList('date,datetime', $tcaFieldConf['dbType'])) {
        // Convert the timestamp back to a date/time
        $emptyValue = $dateTimeFormats[$tcaFieldConf['dbType']]['empty'];
        $format = $dateTimeFormats[$tcaFieldConf['dbType']]['format'];
        $res['value'] = $res['value'] ? date($format, $res['value']) : $emptyValue;
    }

Reviews 2