Skip to content
Permalink
Browse files

Fix auto swith on utf8 when using utf8mb4

  • Loading branch information...
eldy committed May 21, 2019
1 parent eafc35b commit bea4647107335e819fdd6c3ca6627c7a6147b6a3
Showing with 6 additions and 4 deletions.
  1. +6 −4 htdocs/core/db/mysqli.class.php
@@ -141,12 +141,14 @@ public function __construct($type, $host, $user, $pass, $name = '', $port = 0)
// If client is old latin, we force utf8
$clientmustbe=empty($conf->db->dolibarr_main_db_character_set)?'utf8':$conf->db->dolibarr_main_db_character_set;
if (preg_match('/latin1/', $clientmustbe)) $clientmustbe='utf8';
if (preg_match('/utf8mb4/', $clientmustbe)) $clientmustbe='utf8';
if ($this->db->character_set_name() != $clientmustbe) {
$this->db->set_charset($clientmustbe); // This set utf8_general_ci
if ($this->db->character_set_name() != $clientmustbe) {
$this->db->set_charset($clientmustbe); // This set utf8_unicode_ci
$collation = $conf->db->dolibarr_main_db_collation;
if (preg_match('/latin1/', $collation)) $collation='utf8_unicode_ci';
$collation = $conf->db->dolibarr_main_db_collation;
if (preg_match('/latin1/', $collation)) $collation='utf8_unicode_ci';
if (preg_match('/utf8mb4/', $collation)) $collation='utf8_unicode_ci';
if (! preg_match('/general/', $collation)) $this->db->query("SET collation_connection = ".$collation);
}

0 comments on commit bea4647

Please sign in to comment.
You can’t perform that action at this time.