diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 896d6964bdd..1ad1beca350 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -1079,15 +1079,28 @@ if ($ok && GETPOST('force_utf8_on_tables','alpha')) if ($db->type == "mysql" || $db->type == "mysqli") { - $listoftables = $db->DDLListTables($db->database_name); + $force_utf8_on_tables = GETPOST('force_utf8_on_tables','alpha'); + + $listoftables = $db->DDLListTables($db->database_name); + + // Disable foreign key checking for avoid errors + if ($force_utf8_on_tables == 'confirmed') + { + $sql='SET FOREIGN_KEY_CHECKS=0'; + print ''; + $resql = $db->query($sql); + } foreach($listoftables as $table) { + // do not convert llx_const if mysql encrypt/decrypt is used + if ($conf->db->dolibarr_main_db_encryption != 0 && preg_match('/\_const$/', $table)) continue; + print ''; print $table; $sql='ALTER TABLE '.$table.' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci'; print ''; - if (GETPOST('force_utf8_on_tables','alpha') == 'confirmed') + if ($force_utf8_on_tables == 'confirmed') { $resql = $db->query($sql); print ' - Done ('.($resql?'OK':'KO').')'; @@ -1095,6 +1108,14 @@ if ($ok && GETPOST('force_utf8_on_tables','alpha')) else print ' - Disabled'; print ''; } + + // Enable foreign key checking + if ($force_utf8_on_tables == 'confirmed') + { + $sql='SET FOREIGN_KEY_CHECKS=1'; + print ''; + $resql = $db->query($sql); + } } else {