[BUGFIX] Better performance for bulk inserts without static_write 70/35370/2
authorStephan Großberndt <stephan@grossberndt.de>
Tue, 9 Dec 2014 13:52:26 +0000 (14:52 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 12 Dec 2014 19:31:04 +0000 (20:31 +0100)
In DataHandler->fillInFieldArray for every record to insert or update
current and new data are merged to be handed over to the static_write
functionality. If this functionality is disabled (which is the
default) the merged data is discarded again.

Checks if the static_write functionality is enabled and merges data
only if it is enabled. This drastically lowers memory usage for bulk
operations.

In master, the static_write functionality was removed completely,
for 6.2 the performance of this code section is improved.

Resolves: #63668
Releases: 6.2
Change-Id: I625a771a98a5f79bab3a8d22464895fcbdcf4068
Reviewed-on: http://review.typo3.org/35370
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/core/Classes/DataHandling/DataHandler.php

index 5bf2781..92047a5 100644 (file)
@@ -1448,9 +1448,17 @@ class DataHandler {
                $theTypeString = BackendUtility::getTCAtypeValue($table, $currentRecord);
                if (is_array($types_fieldConfig)) {
                        foreach ($types_fieldConfig as $vconf) {
-                               // Write file configuration:
-                               // inserted array_merge($currentRecord,$fieldArray) 170502
-                               $eFile = \TYPO3\CMS\Core\Html\RteHtmlParser::evalWriteFile($vconf['spec']['static_write'], array_merge($currentRecord, $fieldArray));
+                               $eFile = NULL;
+                               if (isset($vconf['spec']['static_write']) && isset($GLOBALS['TYPO3_CONF_VARS']['BE']['staticFileEditPath'])) {
+                                       // only do array_merge if static_write is enabled
+                                       $eFile = \TYPO3\CMS\Core\Html\RteHtmlParser::evalWriteFile($vconf['spec']['static_write'], array_merge($currentRecord, $fieldArray));
+                                       // RteHtmlParser::evalWriteFile will return a string if an error ocurrs
+                                       if (is_string($eFile)) {
+                                               $this->log($table, $id, 2, 0, 1, 'Write-file error: \'%s\'', 13, array($eFile), $realPid);
+                                               // Unset eFile to make checks cheaper
+                                               $eFile = NULL;
+                                       }
+                               }
                                // RTE transformations:
                                if (!$this->dontProcessTransformations) {
                                        if (isset($fieldArray[$vconf['field']])) {
@@ -1460,7 +1468,7 @@ class DataHandler {
                                                                $RTEsetup = $this->BE_USER->getTSConfig('RTE', BackendUtility::getPagesTSconfig($tscPID));
                                                                $thisConfig = BackendUtility::RTEsetup($RTEsetup['properties'], $table, $vconf['field'], $theTypeString);
                                                                // Set alternative relative path for RTE images/links:
-                                                               $RTErelPath = is_array($eFile) ? dirname($eFile['relEditFile']) : '';
+                                                               $RTErelPath = isset($eFile) ? dirname($eFile['relEditFile']) : '';
                                                                // Get RTE object, draw form and set flag:
                                                                $RTEobj = BackendUtility::RTEgetObj();
                                                                if (is_object($RTEobj)) {
@@ -1473,7 +1481,7 @@ class DataHandler {
                                        }
                                }
                                // Write file configuration:
-                               if (is_array($eFile)) {
+                               if (isset($eFile)) {
                                        $mixedRec = array_merge($currentRecord, $fieldArray);
                                        $SW_fileContent = GeneralUtility::getUrl($eFile['editFile']);
                                        $parseHTML = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Html\\RteHtmlParser');
@@ -1490,8 +1498,6 @@ class DataHandler {
                                                        $eFile['statusField'] => $eFile['relEditFile'] . ' updated ' . date('d-m-Y H:i:s') . ', bytes ' . strlen($mixedRec[$eFile['contentField']])
                                                ));
                                        }
-                               } elseif ($eFile && is_string($eFile)) {
-                                       $this->log($table, $id, 2, 0, 1, 'Write-file error: \'%s\'', 13, array($eFile), $realPid);
                                }
                        }
                }