mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-23 07:09:20 +01:00
fix PHP 8.x throws mysqli_sql_exception when it can not connect
This commit is contained in:
parent
f1cba99aa9
commit
b13c1d97b4
@ -544,17 +544,24 @@ class Db
|
|||||||
($Type !== 'mysqli' || ini_get('mysqli.allow_persistent')) ?
|
($Type !== 'mysqli' || ini_get('mysqli.allow_persistent')) ?
|
||||||
'PConnect' : 'Connect';
|
'PConnect' : 'Connect';
|
||||||
|
|
||||||
if (($Ok = $this->Link_ID->$connect($Host, $User, $Password, $Database)))
|
try
|
||||||
{
|
{
|
||||||
$this->ServerInfo = $this->Link_ID->ServerInfo();
|
if (($Ok = $this->Link_ID->$connect($Host, $User, $Password, $Database)))
|
||||||
$this->set_capabilities($Type,$this->ServerInfo['version']);
|
|
||||||
|
|
||||||
// switch off MySQL 5.7+ ONLY_FULL_GROUP_BY sql_mode
|
|
||||||
if (substr($this->Type, 0, 5) == 'mysql' && (float)$this->ServerInfo['version'] >= 5.7 && (float)$this->ServerInfo['version'] < 10.0)
|
|
||||||
{
|
{
|
||||||
$this->query("SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''))", __LINE__, __FILE__);
|
$this->ServerInfo = $this->Link_ID->ServerInfo();
|
||||||
|
$this->set_capabilities($Type, $this->ServerInfo['version']);
|
||||||
|
|
||||||
|
// switch off MySQL 5.7+ ONLY_FULL_GROUP_BY sql_mode
|
||||||
|
if (substr($this->Type, 0, 5) == 'mysql' && (float)$this->ServerInfo['version'] >= 5.7 && (float)$this->ServerInfo['version'] < 10.0)
|
||||||
|
{
|
||||||
|
$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)
|
if (!$Ok)
|
||||||
{
|
{
|
||||||
$Host = preg_replace('/password=[^ ]+/','password=$Password',$Host); // eg. postgres dsn contains password
|
$Host = preg_replace('/password=[^ ]+/','password=$Password',$Host); // eg. postgres dsn contains password
|
||||||
|
Loading…
Reference in New Issue
Block a user