diff --git a/htdocs/admin/system/database-tables.php b/htdocs/admin/system/database-tables.php index cf8f5771b32d2..fa7a86480baac 100644 --- a/htdocs/admin/system/database-tables.php +++ b/htdocs/admin/system/database-tables.php @@ -52,12 +52,30 @@ $db->query($sql); } if ($action == 'convertutf8') { - $sql = "ALTER TABLE ".$db->sanitize($table)." CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci"; - $db->query($sql); + $sql = "ALTER TABLE ".$db->sanitize($table)." CHARACTER SET utf8 COLLATE utf8_unicode_ci"; // Set the default value on table + $resql1 = $db->query($sql); + if (!$resql1) { + setEventMessages($db->lasterror(), null, 'warnings'); + } else { + $sql = "ALTER TABLE ".$db->sanitize($table)." CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci"; // Switch fields (may fails due to foreign key) + $resql2 = $db->query($sql); + if (!$resql2) { + setEventMessages($db->lasterror(), null, 'warnings'); + } + } } if ($action == 'convertutf8mb4') { - $sql = "ALTER TABLE ".$db->sanitize($table)." CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"; - $db->query($sql); + $sql = "ALTER TABLE ".$db->sanitize($table)." CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"; // Set the default value on table + $resql1 = $db->query($sql); + if (!$resql1) { + setEventMessages($db->lasterror(), null, 'warnings'); + } else { + $sql = "ALTER TABLE ".$db->sanitize($table)." CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"; // Switch fields (may fails due to foreign key) + $resql2 = $db->query($sql); + if (!$resql2) { + setEventMessages($db->lasterror(), null, 'warnings'); + } + } } if ($action == 'convertdynamic') { $sql = "ALTER TABLE ".$db->sanitize($table)." ROW_FORMAT=DYNAMIC;";