From 023e99673c70be353e616cc28db394b577e53812 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 29 May 2019 11:28:46 +0200 Subject: [PATCH] do NOT used persistent connections, if they are disabled in php.ini --- api/src/Db.php | 11 ++++++++++- setup/inc/class.setup_header.inc.php | 8 ++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/api/src/Db.php b/api/src/Db.php index 25fb48239f..d12212f715 100644 --- a/api/src/Db.php +++ b/api/src/Db.php @@ -523,7 +523,11 @@ class Db // 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); } - $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))) { $this->ServerInfo = $this->Link_ID->ServerInfo(); @@ -1571,6 +1575,11 @@ class Db { $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)) { $or_null = ''; diff --git a/setup/inc/class.setup_header.inc.php b/setup/inc/class.setup_header.inc.php index e184c2bd68..21a6344c74 100644 --- a/setup/inc/class.setup_header.inc.php +++ b/setup/inc/class.setup_header.inc.php @@ -159,12 +159,8 @@ class setup_header { foreach($egw_domains as $data) { - error_clear_last(); - // check for persistent connection - 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())) + // check if persistent connections are allowed + if (substr($data['db_type'], 0, 5) === 'mysql' && !ini_get('mysqli.allow_persistent')) { $persistent = false; break;