From 3c7b233d9c83b501f5e220a6dcba8259b7554a87 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sun, 22 Jan 2012 11:55:28 +0530 Subject: [PATCH] bug #3477063 [edit] Missing set fields and values in generated INSERT query --- ChangeLog | 1 + libraries/tbl_replace_fields.inc.php | 2 ++ tbl_replace.php | 7 +++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6d8e6b5b3..a61a573b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ phpMyAdmin - ChangeLog - bug #3463933 [display] SELECT DISTINCT displays wrong total records found - patch #3458944 [operations] copy table data missing SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO' - bug #3469254 [edit] Setting data to NULL and drop-downs +- bug #3477063 [edit] Missing set fields and values in generated INSERT query 3.4.9.0 (2011-12-21) - bug #3442028 [edit] Inline editing enum fields with null shows no dropdown diff --git a/libraries/tbl_replace_fields.inc.php b/libraries/tbl_replace_fields.inc.php index 28f5ec39d..b3f125bda 100644 --- a/libraries/tbl_replace_fields.inc.php +++ b/libraries/tbl_replace_fields.inc.php @@ -79,6 +79,8 @@ if (false !== $possibly_uploaded_val) { if (! empty($_REQUEST['fields']['multi_edit'][$rownumber][$key])) { $val = implode(',', $_REQUEST['fields']['multi_edit'][$rownumber][$key]); $val = "'" . PMA_sqlAddslashes($val) . "'"; + } else { + $val = "''"; } } elseif ($type == 'protected') { // here we are in protected mode (asked in the config) diff --git a/tbl_replace.php b/tbl_replace.php index 98d1b28fd..cb26a8760 100644 --- a/tbl_replace.php +++ b/tbl_replace.php @@ -218,7 +218,7 @@ foreach ($loop_array as $rownumber => $where_clause) { if ($is_insert && $using_key && isset($me_fields_type) && is_array($me_fields_type) && isset($where_clause)) { $prot_row = PMA_DBI_fetch_single_row('SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $where_clause . ';'); } - + // When a select field is nullified, it's not present in $_REQUEST // so initialize it; this way, the foreach($me_fields) will process it foreach ($me_fields_name as $key => $val) { @@ -227,7 +227,10 @@ foreach ($loop_array as $rownumber => $where_clause) { } } - foreach ($me_fields as $key => $val) { + // Iterate in the order of $me_fields_name, not $me_fields, to avoid problems + // when inserting multiple entries + foreach ($me_fields_name as $key => $field_name) { + $val = $me_fields[$key]; // Note: $key is an md5 of the fieldname. The actual fieldname is available in $me_fields_name[$key]