[BUGFIX] Avoid to call recordInfo for new records 37/35237/7
authorStephan Großberndt <stephan@grossberndt.de>
Wed, 10 Dec 2014 11:15:53 +0000 (12:15 +0100)
committerMarkus Klein <klein.t3@reelworx.at>
Sun, 1 Feb 2015 21:37:21 +0000 (22:37 +0100)
Avoid to call recordInfo for new records in DataHandler->checkValue by
checking the id. This improves performance for bulk inserts.

Resolves: #63733
Releases: master, 6.2
Change-Id: I02c2d282f487defe3c74d89e7041ecb8b0eae7b8
Reviewed-on: http://review.typo3.org/35237
Reviewed-by: Andreas Fernandez <andreas.fernandez@aspedia.de>
Tested-by: Andreas Fernandez <andreas.fernandez@aspedia.de>
Reviewed-by: Benjamin Mack <benni@typo3.org>
Tested-by: Benjamin Mack <benni@typo3.org>
typo3/sysext/core/Classes/DataHandling/DataHandler.php

index 2aa57ff..fc58b7d 100644 (file)
@@ -1503,7 +1503,6 @@ class DataHandler {
        public function checkValue($table, $field, $value, $id, $status, $realPid, $tscPID) {
                // Result array
                $res = array();
-               $recFID = $table . ':' . $id . ':' . $field;
                // Processing special case of field pages.doktype
                if (($table === 'pages' || $table === 'pages_language_overlay') && $field === 'doktype') {
                        // If the user may not use this specific doktype, we issue a warning
@@ -1525,11 +1524,17 @@ class DataHandler {
                                }
                        }
                }
-               // Get current value:
-               $curValueRec = $this->recordInfo($table, $id, $field);
-               $curValue = $curValueRec[$field];
+               $curValue = NULL;
+               if ((int)$id !== 0) {
+                       // Get current value:
+                       $curValueRec = $this->recordInfo($table, $id, $field);
+                       if (isset($curValueRec[$field])) {
+                               $curValue = $curValueRec[$field];
+                       }
+               }
                // Getting config for the field
                $tcaFieldConf = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
+               $recFID = $table . ':' . $id . ':' . $field;
                // Preform processing:
                $res = $this->checkValue_SW($res, $value, $tcaFieldConf, $table, $id, $curValue, $status, $realPid, $recFID, $field, $this->uploadedFileArray[$table][$id][$field], $tscPID);
                return $res;
@@ -5810,14 +5815,11 @@ class DataHandler {
         */
        public function recordInfo($table, $id, $fieldList) {
                // Skip, if searching for NEW records or there's no TCA table definition
-               if (!(int)$id || !isset($GLOBALS['TCA'][$table])) {
+               if ((int)$id === 0 || !isset($GLOBALS['TCA'][$table])) {
                        return NULL;
                }
                $result = $this->databaseConnection->exec_SELECTgetSingleRow($fieldList, $table, 'uid=' . (int)$id);
-               if ($result) {
-                       return $result;
-               }
-               return NULL;
+               return $result ?: NULL;
        }
 
        /**