From 984a8e3720884511ada2a9c0b78bc5bd1be5a1eb Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 20 Jul 2018 17:28:32 +0200 Subject: [PATCH 1/4] FIX disable/enable foreign key checking for avoid errors --- htdocs/install/repair.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 896d6964bdd..ad63582c142 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -1081,6 +1081,10 @@ if ($ok && GETPOST('force_utf8_on_tables','alpha')) { $listoftables = $db->DDLListTables($db->database_name); + // Disable foreign key checking for avoid errors + $sql='SET FOREIGN_KEY_CHECKS=0'; + $resql = $db->query($sql); + foreach($listoftables as $table) { print ''; @@ -1095,6 +1099,10 @@ if ($ok && GETPOST('force_utf8_on_tables','alpha')) else print ' - Disabled'; print ''; } + + // Enable foreign key checking + $sql='SET FOREIGN_KEY_CHECKS=1'; + $resql = $db->query($sql); } else { From e9d9954380adff4258ae9fa7551b7880a062e92a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 20 Jul 2018 18:33:14 +0200 Subject: [PATCH 2/4] FIX do not convert llx_const if mysql encrypt/decrypt is used --- htdocs/install/repair.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index ad63582c142..269d276d338 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -1087,6 +1087,9 @@ if ($ok && GETPOST('force_utf8_on_tables','alpha')) 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'; From 719db2574e98f29b9255b6143175dba44c1ae3ee Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 20 Jul 2018 18:39:18 +0200 Subject: [PATCH 3/4] FIX check if "confirmed" mode --- htdocs/install/repair.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 269d276d338..8e8aa5017ce 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -1079,11 +1079,16 @@ 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 - $sql='SET FOREIGN_KEY_CHECKS=0'; - $resql = $db->query($sql); + if ($force_utf8_on_tables == 'confirmed') + { + $sql='SET FOREIGN_KEY_CHECKS=0'; + $resql = $db->query($sql); + } foreach($listoftables as $table) { @@ -1094,7 +1099,7 @@ if ($ok && GETPOST('force_utf8_on_tables','alpha')) 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').')'; @@ -1104,8 +1109,11 @@ if ($ok && GETPOST('force_utf8_on_tables','alpha')) } // Enable foreign key checking - $sql='SET FOREIGN_KEY_CHECKS=1'; - $resql = $db->query($sql); + if ($force_utf8_on_tables == 'confirmed') + { + $sql='SET FOREIGN_KEY_CHECKS=1'; + $resql = $db->query($sql); + } } else { From 5cdc9db1f8a29b9466a6f2f5f807d74229ad9c8e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 20 Jul 2018 18:45:52 +0200 Subject: [PATCH 4/4] FIX add html comment --- htdocs/install/repair.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 8e8aa5017ce..1ad1beca350 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -1087,6 +1087,7 @@ if ($ok && GETPOST('force_utf8_on_tables','alpha')) if ($force_utf8_on_tables == 'confirmed') { $sql='SET FOREIGN_KEY_CHECKS=0'; + print ''; $resql = $db->query($sql); } @@ -1112,6 +1113,7 @@ if ($ok && GETPOST('force_utf8_on_tables','alpha')) if ($force_utf8_on_tables == 'confirmed') { $sql='SET FOREIGN_KEY_CHECKS=1'; + print ''; $resql = $db->query($sql); } }