diff --git a/setup/inc/class.setup_cmd_header.inc.php b/setup/inc/class.setup_cmd_header.inc.php index df42593a66..67f9c194b4 100644 --- a/setup/inc/class.setup_cmd_header.inc.php +++ b/setup/inc/class.setup_cmd_header.inc.php @@ -131,6 +131,11 @@ class setup_cmd_header extends setup_cmd { return true; } + // check if php has persistent mysql connections disabled --> disable it in header, to not fill the log with warnings + if ($GLOBALS['egw_info']['server']['db_persistent']) + { + $GLOBALS['egw_info']['server']['db_persistent'] = $this->check_db_persistent($GLOBALS['egw_domain']); + } $header = $this->generate($GLOBALS['egw_info'],$GLOBALS['egw_domain']); if ($this->arguments) diff --git a/setup/inc/class.setup_header.inc.php b/setup/inc/class.setup_header.inc.php index 3cc2594b08..e184c2bd68 100644 --- a/setup/inc/class.setup_header.inc.php +++ b/setup/inc/class.setup_header.inc.php @@ -146,6 +146,34 @@ class setup_header return $errors; } + /** + * Check if any domain using mysql(i) gives a warning about disabled persistent connections + * + * @param array $egw_domains + * @param boolean $persistent =true current value + * @return boolean + */ + function check_db_persistent(array $egw_domains, $persistent=true) + { + if ($persistent !== false) + { + 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())) + { + $persistent = false; + break; + } + } + } + return $persistent; + } + /** * generate header.inc.php file from given values * diff --git a/setup/manageheader.php b/setup/manageheader.php index 241d2c5808..2365254050 100644 --- a/setup/manageheader.php +++ b/setup/manageheader.php @@ -270,6 +270,11 @@ function show_header_form($validation_errors) switch($name) { case 'db_persistent': + if ($GLOBALS['egw_info']['server'][$name] && is_array($GLOBALS['egw_domain'])) + { + $GLOBALS['egw_info']['server'][$name] = $GLOBALS['egw_setup']->header->check_db_persistent($GLOBALS['egw_domain']); + } + // fall through case 'show_domain_selectbox': case 'mcrypt_enabled': $setup_tpl->set_var($name.($GLOBALS['egw_info']['server'][$name] ? '_yes' : '_no'),' selected="selected"');