do NOT used persistent connections, if they are disabled in php.ini

This commit is contained in:
Ralf Becker 2019-05-29 11:28:46 +02:00
parent 75403eea94
commit 4b5890a501
2 changed files with 12 additions and 7 deletions

View File

@ -523,7 +523,11 @@ class Db
// set a connection timeout of 1 second, to allow quicker failover to other db-nodes (default is 20s) // set a connection timeout of 1 second, to allow quicker failover to other db-nodes (default is 20s)
$this->Link_ID->setConnectionParameter(MYSQLI_OPT_CONNECT_TIMEOUT, 1); $this->Link_ID->setConnectionParameter(MYSQLI_OPT_CONNECT_TIMEOUT, 1);
} }
$connect = $GLOBALS['egw_info']['server']['db_persistent'] ? 'PConnect' : 'Connect'; $connect = $GLOBALS['egw_info']['server']['db_persistent'] &&
// do NOT attempt persistent connection, if it is switched off in php.ini (it will only cause a warning)
($Type !== 'mysqli' || ini_get('mysqli.allow_persistent')) ?
'PConnect' : 'Connect';
if (($Ok = $this->Link_ID->$connect($Host, $User, $Password, $Database))) if (($Ok = $this->Link_ID->$connect($Host, $User, $Password, $Database)))
{ {
$this->ServerInfo = $this->Link_ID->ServerInfo(); $this->ServerInfo = $this->Link_ID->ServerInfo();
@ -1571,6 +1575,11 @@ class Db
{ {
$data = array_shift($data); $data = array_shift($data);
} }
// array for SET or VALUES, not WHERE --> automatic store comma-separated
if (is_array($data) && $glue === ',' && in_array($column_type, ['varchar','ascii']))
{
$data = implode(',', $data);
}
if (is_array($data)) if (is_array($data))
{ {
$or_null = ''; $or_null = '';

View File

@ -159,12 +159,8 @@ class setup_header
{ {
foreach($egw_domains as $data) foreach($egw_domains as $data)
{ {
error_clear_last(); // check if persistent connections are allowed
// check for persistent connection if (substr($data['db_type'], 0, 5) === 'mysql' && !ini_get('mysqli.allow_persistent'))
if (substr($data['db_type'], 0, 5) === 'mysql' &&
function_exists('mysqli_connect') &&
@mysqli_connect('p:'.$data['db_host']) &&
preg_match('/Persistent connections are disabled/i', error_get_last()))
{ {
$persistent = false; $persistent = false;
break; break;