check if persistent mysql connections are disabled --> disable them in header

This commit is contained in:
Ralf Becker 2019-05-28 13:38:21 +02:00
parent 294657b825
commit 2d039afe8d
3 changed files with 38 additions and 0 deletions

View File

@ -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)

View File

@ -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
*

View File

@ -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"');