fix PHP 8.x throws mysqli_sql_exception when it can not connect

This commit is contained in:
ralf 2022-09-09 08:24:20 +02:00
parent f1cba99aa9
commit b13c1d97b4

View File

@ -544,6 +544,8 @@ class Db
($Type !== 'mysqli' || ini_get('mysqli.allow_persistent')) ?
'PConnect' : 'Connect';
try
{
if (($Ok = $this->Link_ID->$connect($Host, $User, $Password, $Database)))
{
$this->ServerInfo = $this->Link_ID->ServerInfo();
@ -555,6 +557,11 @@ class Db
$this->query("SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''))", __LINE__, __FILE__);
}
}
}
catch (\mysqli_sql_exception $e) {
_egw_log_exception($e);
$Ok = false;
}
if (!$Ok)
{
$Host = preg_replace('/password=[^ ]+/','password=$Password',$Host); // eg. postgres dsn contains password