diff --git a/ChangeLog b/ChangeLog index efd612a7cb..69e7b8d8fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -53,6 +53,7 @@ phpMyAdmin - ChangeLog + rfe Remove support for Shift + Click on function name to apply to all rows in insert/edit page + rfe #1634 Don't group tables in tree if the result has only one group - bug #4946 When hide table structure actions is false, action should be in a row ++ rfe #726 Batch changing the collation of each column in a table 4.4.10.0 (not yet released) - bug #4950 Issues in database selection for replication diff --git a/js/messages.php b/js/messages.php index 3ba1f8d20d..90256329b4 100644 --- a/js/messages.php +++ b/js/messages.php @@ -73,6 +73,16 @@ $js_messages['strChangeColumnCollation'] = __( . '' . __('Garbled Data') . '.' . '

' . __('Are you sure you wish to change the collation and convert the data?'); +$js_messages['strChangeAllColumnCollationsWarning'] = __( + 'Through this operation, MySQL attempts to map the data values between collations. ' + . 'If the character sets are incompatible, ' + . 'there may be data loss and this lost data may NOT be recoverable simply ' + . 'by changing back the column collation(s).' + . ' To convert existing data, it is suggested to use the column(s) editing feature ' + . '(the "Change" Link) on the table structure page. ' +) +. '

' +. __('Are you sure you wish to change all the column collations and convert the data?'); /* For modal dialog buttons */ $js_messages['strSaveAndClose'] = __('Save & Close'); diff --git a/js/tbl_operations.js b/js/tbl_operations.js index 9665eb2d9b..781f0d5b83 100644 --- a/js/tbl_operations.js +++ b/js/tbl_operations.js @@ -78,10 +78,35 @@ AJAX.registerOnload('tbl_operations.js', function () { event.stopPropagation(); var $form = $(this); var $tblNameField = $form.find('input[name=new_name]'); + var $tblCollationField = $form.find('select[name=tbl_collation]'); + var collationOrigValue = $('select[name="tbl_collation"] option[selected]').val(); + var $changeAllColumnCollationsCheckBox = $('#checkbox_change_all_collations'); + var question = PMA_messages.strChangeAllColumnCollationsWarning; + if ($tblNameField.val() !== $tblNameField[0].defaultValue) { // reload page and navigation if the table has been renamed PMA_prepareForAjaxRequest($form); var tbl = $tblNameField.val(); + + if ($tblCollationField.val() !== collationOrigValue && $changeAllColumnCollationsCheckBox.is(':checked')) { + $form.PMA_confirm(question, $form.attr('action'), function (url) { + submitOptionsForm(); + }); + } else { + submitOptionsForm(); + } + } else { + + if ($tblCollationField.val() !== collationOrigValue && $changeAllColumnCollationsCheckBox.is(':checked')) { + $form.PMA_confirm(question, $form.attr('action'), function (url) { + $form.removeClass('ajax').submit().addClass('ajax'); + }); + } else { + $form.removeClass('ajax').submit().addClass('ajax'); + } + } + + function submitOptionsForm() { $.post($form.attr('action'), $form.serialize(), function (data) { if (typeof data !== 'undefined' && data.success === true) { PMA_commonParams.set('table', tbl); @@ -93,8 +118,6 @@ AJAX.registerOnload('tbl_operations.js', function () { PMA_ajaxShowMessage(data.error, false); } }); // end $.post() - } else { - $form.removeClass('ajax').submit().addClass('ajax'); } }); diff --git a/libraries/Console.class.php b/libraries/Console.class.php index 1b3b86ccd6..4074effce1 100644 --- a/libraries/Console.class.php +++ b/libraries/Console.class.php @@ -164,7 +164,7 @@ class PMA_Console $output = ''; $_sql_history = PMA_getHistory($GLOBALS['cfg']['Server']['user']); - if ($_sql_history) { + if (! empty($_sql_history)) { foreach (array_reverse($_sql_history) as $record) { $isSelect = preg_match( '@^SELECT[[:space:]]+@i', $record['sqlquery'] diff --git a/libraries/insert_edit.lib.php b/libraries/insert_edit.lib.php index ec805ab8b9..f2394e82c3 100644 --- a/libraries/insert_edit.lib.php +++ b/libraries/insert_edit.lib.php @@ -1497,11 +1497,12 @@ function PMA_getAfterInsertDropDown($where_clause, $after_insert, $found_unique_ $where_clause = array($where_clause); } for ($i = 0, $nb = count($where_clause); $i < $nb; $i++) { - $is_numeric = preg_match( + // preg_match() returns 1 if there is a match + $is_numeric = (preg_match( '@^[\s]*`[^`]*`[\.]`[^`]*` = [0-9]+@', $where_clause[$i] - ); - if ($is_numeric == true) { + ) == 1); + if ($is_numeric === true) { break; } } diff --git a/libraries/operations.lib.php b/libraries/operations.lib.php index 58f012497d..6f404d5763 100644 --- a/libraries/operations.lib.php +++ b/libraries/operations.lib.php @@ -989,6 +989,15 @@ function PMA_getTableOptionFieldset($comment, $tbl_collation, . '' . ''; + // Change all Column collations + $html_output .= '' + . '' + . '' + . ''; + if ($is_myisam_or_aria || $is_isam) { $html_output .= PMA_getHtmlForPackKeys($pack_keys); } // end if (MYISAM|ISAM) @@ -1909,6 +1918,30 @@ function PMA_AdjustPrivileges_copyTable($oldDb, $oldTable, $newDb, $newTable) } +/** + * Change all collations and character sets of all columns in table + * + * @param string $db Database name + * @param string $table Table name + * @param string $tbl_collation Collation Name + * + * @return void + */ +function PMA_changeAllColumnsCollation($db, $table, $tbl_collation) +{ + $GLOBALS['dbi']->selectDb($db); + + $change_all_collations_query = 'ALTER TABLE ' . $table + . ' CONVERT TO'; + + list($charset) = explode('_', $tbl_collation); + + $change_all_collations_query .= ' CHARACTER SET ' . $charset + . ($charset == $tbl_collation ? '' : ' COLLATE ' . $tbl_collation); + + $GLOBALS['dbi']->query($change_all_collations_query); +} + /** * Move or copy a table * diff --git a/po/nb.po b/po/nb.po index 946c810722..8c462a3a62 100644 --- a/po/nb.po +++ b/po/nb.po @@ -4,8 +4,8 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.5.0-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2015-05-31 07:27-0400\n" -"PO-Revision-Date: 2015-06-04 19:48+0200\n" -"Last-Translator: Kurt Eilertsen \n" +"PO-Revision-Date: 2015-06-09 13:19+0200\n" +"Last-Translator: Børge Holm-Wennberg \n" "Language-Team: Norwegian Bokmål " "\n" "Language: nb\n" @@ -7563,7 +7563,7 @@ msgstr "" #: libraries/config/messages.inc.php:658 #: libraries/display_create_database.lib.php:31 msgid "Database name" -msgstr "Ddatabasenavn" +msgstr "Databasenavn" #: libraries/config/messages.inc.php:660 #, fuzzy diff --git a/tbl_operations.php b/tbl_operations.php index 686df60abf..ed99ceac46 100644 --- a/tbl_operations.php +++ b/tbl_operations.php @@ -178,6 +178,16 @@ if (isset($_REQUEST['submitoptions'])) { unset($table_alters); $warning_messages = PMA_getWarningMessagesArray(); } + + if (isset($_REQUEST['tbl_collation']) + && ! empty($_REQUEST['tbl_collation']) + && isset($_REQUEST['change_all_collations']) + && ! empty($_REQUEST['change_all_collations']) + ) { + PMA_changeAllColumnsCollation( + $GLOBALS['db'], $GLOBALS['table'], $_REQUEST['tbl_collation'] + ); + } } /** * Reordering the table has been requested by the user