[BUGFIX] Insert rows only once in exec_INSERTmultipleRows 85/21085/2
authorJigal van Hemert <jigal@xs4all.nl>
Wed, 15 May 2013 19:07:50 +0000 (21:07 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Fri, 14 Jun 2013 00:13:19 +0000 (02:13 +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/21085
Tested-by: Alexander Opitz
Reviewed-by: Alexander Opitz
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/dbal/Classes/Database/DatabaseConnection.php

index ad837c0..5c24978 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);