mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-31 14:12:29 +01:00
NEW Add maintenance tool to switch utf8 -> utf8mb4
This commit is contained in:
@@ -39,6 +39,7 @@ if (!$user->admin) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$table = GETPOST('table', 'aZ09');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
|
||||
|
||||
@@ -46,16 +47,20 @@ $action = GETPOST('action', 'aZ09');
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'convert') {
|
||||
$sql = "ALTER TABLE ".$db->escape(GETPOST("table", "aZ09"))." ENGINE=INNODB";
|
||||
if ($action == 'convert') { // Convert engine into innodb
|
||||
$sql = "ALTER TABLE ".$db->sanitize($table)." ENGINE=INNODB";
|
||||
$db->query($sql);
|
||||
}
|
||||
if ($action == 'convertutf8') {
|
||||
$sql = "ALTER TABLE ".$db->escape(GETPOST("table", "aZ09"))." CHARACTER SET utf8 COLLATE utf8_unicode_ci";
|
||||
$sql = "ALTER TABLE ".$db->sanitize($table)." CHARACTER SET utf8 COLLATE utf8_unicode_ci";
|
||||
$db->query($sql);
|
||||
}
|
||||
if ($action == 'convertutf8mb4') {
|
||||
$sql = "ALTER TABLE ".$db->sanitize($table)." CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci";
|
||||
$db->query($sql);
|
||||
}
|
||||
if ($action == 'convertdynamic') {
|
||||
$sql = "ALTER TABLE ".$db->escape(GETPOST("table", "aZ09"))." ROW_FORMAT=DYNAMIC;";
|
||||
$sql = "ALTER TABLE ".$db->sanitize($table)." ROW_FORMAT=DYNAMIC;";
|
||||
$db->query($sql);
|
||||
}
|
||||
|
||||
@@ -160,17 +165,24 @@ if (!$base) {
|
||||
print '<br><a class="reposition" href="database-tables.php?action=convertdynamic&table='.urlencode($obj->Name).'&token='.newToken().'">'.$langs->trans("Convert").' Dynamic</a>';
|
||||
}
|
||||
print '</td>';
|
||||
print '<td align="right">'.$obj->Rows.'</td>';
|
||||
print '<td align="right">'.$obj->Avg_row_length.'</td>';
|
||||
print '<td align="right">'.$obj->Data_length.'</td>';
|
||||
print '<td align="right">'.$obj->Max_data_length.'</td>';
|
||||
print '<td align="right">'.$obj->Index_length.'</td>';
|
||||
print '<td align="right">'.$obj->Auto_increment.'</td>';
|
||||
print '<td align="right">'.$obj->Check_time.'</td>';
|
||||
print '<td align="right">'.$obj->Collation;
|
||||
// Accept utf8, utf8mb3_unicode_ci, utf8mb4_unicode_ci
|
||||
if (isset($obj->Collation) && (in_array($obj->Collation, array("utf8mb4_general_ci", "latin1_swedish_ci")))) {
|
||||
print '<br><a class="reposition" href="database-tables.php?action=convertutf8&table='.urlencode($obj->Name).'&token='.newToken().'">'.$langs->trans("Convert").' UTF8</a>';
|
||||
print '<td class="right">'.$obj->Rows.'</td>';
|
||||
print '<td class="right">'.$obj->Avg_row_length.'</td>';
|
||||
print '<td class="right">'.$obj->Data_length.'</td>';
|
||||
print '<td class="right">'.$obj->Max_data_length.'</td>';
|
||||
print '<td class="right">'.$obj->Index_length.'</td>';
|
||||
print '<td class="right">'.$obj->Auto_increment.'</td>';
|
||||
print '<td class="right">'.$obj->Check_time.'</td>';
|
||||
print '<td class="right nowraponall">'.$obj->Collation;
|
||||
// Link to convert collation
|
||||
if (isset($obj->Collation)) {
|
||||
print '<br><span class="opacitymedium small">'.$langs->trans("ConvertInto");
|
||||
if (!in_array($obj->Collation, array("utf8_unicode_ci"))) {
|
||||
print ' <a class="reposition" href="database-tables.php?action=convertutf8&table='.urlencode($obj->Name).'&token='.newToken().'">utf8</a>';
|
||||
}
|
||||
if (!in_array($obj->Collation, array("utf8mb4_unicode_ci"))) {
|
||||
print ' <a class="reposition" href="database-tables.php?action=convertutf8mb4&table='.urlencode($obj->Name).'&token='.newToken().'">utf8mb4</a>';
|
||||
}
|
||||
print '</span>';
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
Reference in New Issue
Block a user