Fix pb with mix collation. Add a way to fix this in repair.

This commit is contained in:
Laurent Destailleur 2017-08-04 21:23:40 +02:00
parent e039f7cc22
commit 1c157c7c3d
2 changed files with 32 additions and 23 deletions

View File

@ -146,7 +146,7 @@ function run_sql($sqlfile,$silent=1,$entity='',$usesavepoint=1,$handler='',$oker
$buf = fgets($fp, 4096); $buf = fgets($fp, 4096);
// Test if request must be ran only for particular database or version (if yes, we must remove the -- comment) // Test if request must be ran only for particular database or version (if yes, we must remove the -- comment)
if (preg_match('/^--\sV(MYSQL|PGSQL|)([0-9\.]+)/i',$buf,$reg)) if (preg_match('/^--\sV(MYSQL|PGSQL)([^\s]*)/i',$buf,$reg))
{ {
$qualified=1; $qualified=1;
@ -159,20 +159,29 @@ function run_sql($sqlfile,$silent=1,$entity='',$usesavepoint=1,$handler='',$oker
// restrict on version // restrict on version
if ($qualified) if ($qualified)
{ {
if (! empty($reg[2]))
$versionrequest=explode('.',$reg[2]); {
//print var_dump($versionrequest); if (is_numeric($reg[2])) // This is a version
//print var_dump($versionarray); {
if (! count($versionrequest) || ! count($versionarray) || versioncompare($versionrequest,$versionarray) > 0) $versionrequest=explode('.',$reg[2]);
{ //print var_dump($versionrequest);
$qualified=0; //print var_dump($versionarray);
} if (! count($versionrequest) || ! count($versionarray) || versioncompare($versionrequest,$versionarray) > 0)
{
$qualified=0;
}
}
else // This is a test on a constant. For example when we have -- VMYSQLUTF8UNICODE, we test constant $conf->global->UTF8UNICODE
{
if (empty($conf->db->dolibarr_main_db_collation) || ($reg[2] != strtoupper(preg_replace('/_/', '', $conf->db->dolibarr_main_db_collation)))) $qualified=0;
}
}
} }
if ($qualified) if ($qualified)
{ {
// Version qualified, delete SQL comments // Version qualified, delete SQL comments
$buf=preg_replace('/^--\sV(MYSQL|PGSQL|)([0-9\.]+)/i','',$buf); $buf=preg_replace('/^--\sV(MYSQL|PGSQL)([^\s]*)/i','',$buf);
//print "Ligne $i qualifi?e par version: ".$buf.'<br>'; //print "Ligne $i qualifi?e par version: ".$buf.'<br>';
} }
} }
@ -769,7 +778,7 @@ function activateModule($value,$withdeps=1)
} }
$result=$objMod->init(); $result=$objMod->init();
if ($result <= 0) if ($result <= 0)
{ {
$ret['errors'][]=$objMod->error; $ret['errors'][]=$objMod->error;
} }
@ -799,19 +808,19 @@ function activateModule($value,$withdeps=1)
break; break;
} }
} }
if ($activate) if ($activate)
{ {
$ret['nbmodules']+=$resarray['nbmodules']; $ret['nbmodules']+=$resarray['nbmodules'];
$ret['nbperms']+=$resarray['nbperms']; $ret['nbperms']+=$resarray['nbperms'];
} }
else else
{ {
$ret['errors'][] = $langs->trans('activateModuleDependNotSatisfied', $objMod->name, $objMod->depends[$i]); $ret['errors'][] = $langs->trans('activateModuleDependNotSatisfied', $objMod->name, $objMod->depends[$i]);
} }
} }
} }
if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && ! empty($objMod->conflictwith)) if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && ! empty($objMod->conflictwith))
{ {
// Desactivation des modules qui entrent en conflit // Desactivation des modules qui entrent en conflit
@ -830,12 +839,12 @@ function activateModule($value,$withdeps=1)
} }
} }
if (! count($ret['errors'])) if (! count($ret['errors']))
{ {
$ret['nbmodules']++; $ret['nbmodules']++;
$ret['nbperms']+=count($objMod->rights); $ret['nbperms']+=count($objMod->rights);
} }
return $ret; return $ret;
} }
@ -1307,7 +1316,7 @@ function showModulesExludedForExternal($modules)
//if (empty($conf->global->$moduleconst)) continue; //if (empty($conf->global->$moduleconst)) continue;
if (! in_array($modulename,$listofmodules)) continue; if (! in_array($modulename,$listofmodules)) continue;
//var_dump($modulename.'eee'.$langs->trans('Module'.$module->numero.'Name')); //var_dump($modulename.'eee'.$langs->trans('Module'.$module->numero.'Name'));
if ($i > 0) $text.=', '; if ($i > 0) $text.=', ';
else $text.=' '; else $text.=' ';
$i++; $i++;

View File

@ -27,12 +27,12 @@
-- VMYSQLUTF8UNICODE ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) CHARACTER SET utf8; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) CHARACTER SET utf8;
-- VMYSQLUTF8UNICODE ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci;
-- VMYSQLUTF8UNICODE ALTER TABLE llx_stock_mouvement MODIFY batch VARCHAR(30) CHARACTER SET utf8; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_stock_mouvement MODIFY batch VARCHAR(30) CHARACTER SET utf8;
-- VMYSQLUTF8UNICODE ALTER TABLE llx_stock_mouvement MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_stock_mouvement MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci;
-- VMYSQLUTF8UNICODE ALTER TABLE llx_product_lot MODIFY batch VARCHAR(30) CHARACTER SET utf8; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_product_lot MODIFY batch VARCHAR(30) CHARACTER SET utf8;
-- VMYSQLUTF8UNICODE ALTER TABLE llx_product_lot MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_product_lot MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci;