2
0
forked from Wavyzz/dolibarr
This commit is contained in:
Laurent Destailleur
2024-09-12 02:21:14 +02:00
parent 0d62dc8ecd
commit a52963020d
2 changed files with 10 additions and 5 deletions

View File

@@ -59,12 +59,14 @@ print '<tr class="oddeven"><td width="300">'.$langs->trans("User").'</td><td>'.$
print '<tr class="oddeven"><td width="300">'.$langs->trans("Password").'</td><td>'.preg_replace('/./i', '*', $dolibarr_main_db_pass).'</td></tr>'."\n";
print '<tr class="oddeven"><td width="300">'.$langs->trans("DBStoringCharset").'</td><td>'.$db->getDefaultCharacterSetDatabase();
if ($db->type == 'mysqli') {
print ' '.$form->textwithpicto('', $langs->transnoentitiesnoconv("HelpMariaDBToGetPossibleValues", "SHOW CHARACTER SET"));
print ' '.$form->textwithpicto('', $langs->transnoentitiesnoconv("HelpMariaDBToGetPossibleValues", "SHOW CHARSET"));
// We can use $db->getDefaultCharacterSetDatabase(), $db->getListOfCharacterSet(),
}
print '</td></tr>'."\n";
print '<tr class="oddeven"><td width="300">'.$langs->trans("DBSortingCharset").'</td><td>'.$db->getDefaultCollationDatabase();
if ($db->type == 'mysqli') {
print ' '.$form->textwithpicto('', $langs->transnoentitiesnoconv("HelpMariaDBToGetPossibleValues", "SHOW COLLATION"));
// We can use $db->getDefaultCollationDatabase(), $db->getListOfCollation();
}
print '</td></tr>'."\n";
print '</table>';

View File

@@ -121,11 +121,14 @@ class DoliDBMysqli extends DoliDB
$disableforcecharset = 0; // Set to 1 to test without charset forcing
if (empty($disableforcecharset) && $this->db->character_set_name() != $clientmustbe) {
try {
//print "You should set the \$dolibarr_main_db_character_set and \$dolibarr_main_db_collation for the PHP to the one of the database, so to ".$this->db->character_set_name();
dol_syslog(get_class($this)."::DoliDBMysqli You should set the \$dolibarr_main_db_character_set and \$dolibarr_main_db_collation for the PHP to the one of the database, so to ".$this->db->character_set_name(), LOG_WARNING);
//
dol_syslog(get_class($this)."::DoliDBMysqli You should set the \$dolibarr_main_db_character_set and \$dolibarr_main_db_collation for the PHP to the same as the database default, so to ".$this->db->character_set_name(). " or upgrade database default to ".$clientmustbe.".", LOG_WARNING);
// To get current charset: USE databasename; SHOW VARIABLES LIKE 'character_set_database'
// or: USE databasename; SELECT schema_name, default_character_set_name FROM information_schema.SCHEMATA;
// To get current collation: USE databasename; SHOW VARIABLES LIKE 'collation_database'
// or: USE databasename; SELECT schema_name, default_character_set_name FROM information_schema.SCHEMATA;
// To upgrade database default, you can do: ALTER DATABASE databasename CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
$this->db->set_charset($clientmustbe); // This set charset, but with a bad collation
$this->db->set_charset($clientmustbe); // This set charset, but with a bad collation (colllation is forced later)
} catch (Exception $e) {
print 'Failed to force character_set_client to '.$clientmustbe." (according to setup) to match the one of the server database.<br>\n";
print $e->getMessage();