fix PHP 8.1 error/mysqli_sql_exception: Invalid character set was provided (utf-8 instead of utf8)

This commit is contained in:
ralf 2022-04-04 10:19:26 +03:00
parent 6c31c40ddf
commit a2bc71d7fc

View File

@ -227,9 +227,12 @@ class Egw extends Egw\Base
// for the migration: reference us to the old phpgw object
$GLOBALS['phpgw'] =& $this;
if ($GLOBALS['egw_info']['server']['system_charset'])
{
$this->db->Link_ID->SetCharSet($GLOBALS['egw_info']['server']['system_charset']);
try {
// set our default charset
$this->db->Link_ID->SetCharSet($this->db->Type === 'mysql' ? 'utf8' : 'utf-8');
}
catch (\Throwable $e) {
_egw_log_exception($e);
}
// restoring server timezone, to avoid warnings under php5.3
if (!empty($GLOBALS['egw_info']['server']['server_timezone']))
@ -621,4 +624,4 @@ class Egw extends Egw\Base
$this->db->disconnect();
}
}
}
}