From 3ea8e7d87beb54771a1ca8e4553405f393f565bf Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Mon, 26 Mar 2012 13:01:07 -0400 Subject: [PATCH 1/2] Patch #3510656 Contest-1 Ignoring foreign keys while dropping tables --- js/db_structure.js | 22 ++++++++++++++++++++++ js/messages.php | 3 +++ libraries/mult_submits.inc.php | 19 ++++++++++++++++++- themes/original/css/theme_right.css.php | 6 ++++++ themes/pmahomme/css/theme_right.css.php | 6 ++++++ 5 files changed, 55 insertions(+), 1 deletion(-) diff --git a/js/db_structure.js b/js/db_structure.js index 5151bcaf38..5e205ed2af 100644 --- a/js/db_structure.js +++ b/js/db_structure.js @@ -253,6 +253,28 @@ $(document).ready(function() { }) // end $.post() }); + /** + * Event handler for 'Foreign Key Checks' disabling option + * in the drop table confirmation form + */ + $(".fkc_switch").click(function(event){ + if ($("#fkc_checkbox").attr('checked') == 'checked') { + $("#fkc_checkbox").removeAttr('checked'); + $("#fkc_status").html(PMA_messages['strForeignKeyCheckDisabled']); + return; + } + $("#fkc_checkbox").attr('checked','checked'); + $("#fkc_status").html(PMA_messages['strForeignKeyCheckEnabled']); + }); + + $('#fkc_checkbox').change(function () { + if ($(this).attr("checked")) { + $("#fkc_status").html(PMA_messages['strForeignKeyCheckEnabled']); + return; + } + $("#fkc_status").html(PMA_messages['strForeignKeyCheckDisabled']); + }); // End of event handler for 'Foreign Key Check' + /** * Ajax Event handler for 'Truncate Table' * diff --git a/js/messages.php b/js/messages.php index a9701430d6..600273b98d 100644 --- a/js/messages.php +++ b/js/messages.php @@ -247,6 +247,9 @@ $js_messages['strNo'] = __('No'); $js_messages['strInsertTable'] = __('Insert Table'); $js_messages['strHideIndexes'] = __('Hide indexes'); $js_messages['strShowIndexes'] = __('Show indexes'); +$js_messages['strForeignKeyCheck'] = __('Foreign Key Check:'); +$js_messages['strForeignKeyCheckEnabled'] = __('(Enabled)'); +$js_messages['strForeignKeyCheckDisabled'] = __('(Disabled)'); /* For db_search.js */ $js_messages['strSearching'] = __('Searching'); diff --git a/libraries/mult_submits.inc.php b/libraries/mult_submits.inc.php index 0045a90159..977b50b217 100644 --- a/libraries/mult_submits.inc.php +++ b/libraries/mult_submits.inc.php @@ -294,7 +294,17 @@ if (!empty($submit_mult) && !empty($what)) { ?>: -
+
+
+ + /> + +
@@ -464,6 +474,7 @@ if (!empty($submit_mult) && !empty($what)) { } // end for if ($query_type == 'drop_tbl') { + $default_fk_check_value = (PMA_DBI_fetch_value('SHOW VARIABLES LIKE \'foreign_key_checks\';', 0, 1) == 'ON') ? 1 : 0; if (!empty($sql_query)) { $sql_query .= ';'; } elseif (!empty($sql_query_views)) { @@ -476,7 +487,13 @@ if (!empty($submit_mult) && !empty($what)) { include './sql.php'; } elseif (!$run_parts) { PMA_DBI_select_db($db); + if(!isset($_REQUEST['fk_check']) && $query_type == 'drop_tbl') { // for disabling foreign key checks while dropping tables + PMA_DBI_query('SET FOREIGN_KEY_CHECKS = 0;'); + } $result = PMA_DBI_try_query($sql_query); + if(!isset($_REQUEST['fk_check']) && $query_type == 'drop_tbl' && $default_fk_check_value) { + PMA_DBI_query('SET FOREIGN_KEY_CHECKS = 1;'); + } if ($result && !empty($sql_query_views)) { $sql_query .= ' ' . $sql_query_views . ';'; $result = PMA_DBI_try_query($sql_query_views); diff --git a/themes/original/css/theme_right.css.php b/themes/original/css/theme_right.css.php index d2f50e663f..712f595e5c 100644 --- a/themes/original/css/theme_right.css.php +++ b/themes/original/css/theme_right.css.php @@ -3041,6 +3041,12 @@ h2.active { color: black; font-weight: normal; } + +#foreignkeychk { + align:left; + position:absolute; + cursor:pointer; +} input.btn { color:#333; diff --git a/themes/pmahomme/css/theme_right.css.php b/themes/pmahomme/css/theme_right.css.php index 8ca74ecd23..6714b55c75 100644 --- a/themes/pmahomme/css/theme_right.css.php +++ b/themes/pmahomme/css/theme_right.css.php @@ -3578,6 +3578,12 @@ h2.active { color: black; font-weight: normal; } + +#foreignkeychk { + align:left; + position:absolute; + cursor:pointer; +} input.btn { color: #333; From 8f4011be01a8245c7e5190465bcb246df892d9da Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Mon, 26 Mar 2012 13:03:53 -0400 Subject: [PATCH 2/2] ChangeLog entry Remove uppercase characters in the message --- ChangeLog | 1 + js/messages.php | 2 +- libraries/mult_submits.inc.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3c9fcc92eb..e22515d366 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,7 @@ phpMyAdmin - ChangeLog + rfe #3488640 Expand table-group in non-light navigation frame if only one + Patch #3509360 Contest-3: Option "Truncate table" before "insert" + Patch #3506552 Contest-2: Show index information in the data dictionary ++ Patch #3510656 Contest-1: Ignoring foreign keys while dropping tables 3.5.1.0 (not yet released) diff --git a/js/messages.php b/js/messages.php index 600273b98d..6d573f2e7d 100644 --- a/js/messages.php +++ b/js/messages.php @@ -247,7 +247,7 @@ $js_messages['strNo'] = __('No'); $js_messages['strInsertTable'] = __('Insert Table'); $js_messages['strHideIndexes'] = __('Hide indexes'); $js_messages['strShowIndexes'] = __('Show indexes'); -$js_messages['strForeignKeyCheck'] = __('Foreign Key Check:'); +$js_messages['strForeignKeyCheck'] = __('Foreign key check:'); $js_messages['strForeignKeyCheckEnabled'] = __('(Enabled)'); $js_messages['strForeignKeyCheckDisabled'] = __('(Disabled)'); diff --git a/libraries/mult_submits.inc.php b/libraries/mult_submits.inc.php index 977b50b217..d48616a41b 100644 --- a/libraries/mult_submits.inc.php +++ b/libraries/mult_submits.inc.php @@ -298,7 +298,7 @@ if (!empty($submit_mult) && !empty($what)) { // Display option to disable foreign key checks while dropping tables if ($what == 'drop_tbl') { ?>
- + />