[BUGFIX] Insert rows only once in exec_INSERTmultipleRows 05/21405/2
authorJigal van Hemert <jigal@xs4all.nl>
Wed, 15 May 2013 19:07:50 +0000 (21:07 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 22 Jun 2013 23:18:33 +0000 (01:18 +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
Related: #34327
Reviewed-on: https://review.typo3.org/21405
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/dbal/Classes/Database/DatabaseConnection.php

index 371c04a..93a1e74 100644 (file)
@@ -549,17 +549,18 @@ class DatabaseConnection extends \TYPO3\CMS\Core\Database\DatabaseConnection {
                        if ($this->lastHandlerKey === '_DEFAULT' && !$this->isConnected()) {
                                $this->connectDB();
                        }
-                       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);
                }
                foreach ($this->postProcessHookObjects as $hookObject) {
                        $hookObject->exec_INSERTmultipleRows_postProcessAction($table, $fields, $rows, $no_quote_fields, $this);