[BUGFIX] Insert rows only once in exec_INSERTmultipleRows 08/21408/2
authorJigal van Hemert <jigal@xs4all.nl>
Fri, 14 Jun 2013 00:30:42 +0000 (02:30 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 22 Jun 2013 23:19:49 +0000 (01:19 +0200)
For native handler types multiple rows can be inserted using the mysql
INSERTmultipleRows API call. When another handler was used, the operation
was done twice, due to a missing else after the native handler condition.
This resulted in two database records for every INSERT statement.

The patch adds the missing else branch for the condition, preventing
the second run that was only meant to handle non-native handler types.

Change-Id: Ibab98a0c73b379bac063c8d1c19e30e93f38faf4
Resolves: #48220
Releases: 6.2, 6.1, 6.0, 4.7, 4.5
Reviewed-on: https://review.typo3.org/21408
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/dbal/class.ux_t3lib_db.php

index 8c5f32b..b03a0e7 100644 (file)
@@ -583,18 +583,18 @@ class ux_t3lib_DB extends t3lib_DB {
        public function exec_INSERTmultipleRows($table, array $fields, array $rows, $no_quote_fields = FALSE) {
                if ((string) $this->handlerCfg[$this->lastHandlerKey]['type'] === 'native') {
                        $this->lastHandlerKey = $this->handler_getFromTableList($table);
-                       mysql_query(
+                       $res = mysql_query(
                                parent::INSERTmultipleRows($table, $fields, $rows, $no_quote_fields),
                                $this->handlerInstance[$this->lastHandlerKey]['link']
                        );
-               }
-
-               foreach ($rows as $row) {
-                       $fields_values = array();
-                       foreach ($fields as $key => $value) {
-                               $fields_values[$value] = $row[$key];
+               } else {
+                       foreach ($rows as $row) {
+                               $fields_values = array();
+                               foreach ($fields as $key => $value) {
+                                       $fields_values[$value] = $row[$key];
+                               }
+                               $res = $this->exec_INSERTquery($table, $fields_values, $no_quote_fields);
                        }
-                       $res = $this->exec_INSERTquery($table, $fields_values, $no_quote_fields);
                }
 
                return $res;