Move PHP confguration to Core class

Issue #11731

Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
Michal Čihař 2017-09-04 17:34:04 +02:00
parent fee96096e7
commit dffa9f06b7
2 changed files with 30 additions and 16 deletions

View File

@ -1099,4 +1099,32 @@ class Core
return unserialize($data);
}
/**
* Applies changes to PHP configuration.
*
* @return void
*/
public static function configure()
{
/**
* Set utf-8 encoding for PHP
*/
ini_set('default_charset', 'utf-8');
mb_internal_encoding('utf-8');
/**
* Set precision to sane value, with higher values
* things behave slightly unexpectedly, for example
* round(1.2, 2) returns 1.199999999999999956.
*/
ini_set('precision', 14);
/**
* check timezone setting
* this could produce an E_WARNING - but only once,
* if not done here it will produce E_WARNING on every date/time function
*/
date_default_timezone_set(@date_default_timezone_get());
}
}

View File

@ -109,17 +109,9 @@ $GLOBALS['error_handler'] = new ErrorHandler();
Core::checkExtensions();
/**
* Set utf-8 encoding for PHP
* Configure required PHP settings.
*/
ini_set('default_charset', 'utf-8');
mb_internal_encoding('utf-8');
/**
* Set precision to sane value, with higher values
* things behave slightly unexpectedly, for example
* round(1.2, 2) returns 1.199999999999999956.
*/
ini_set('precision', 14);
Core::configure();
/******************************************************************************/
/* start procedural code label_start_procedural */
@ -206,12 +198,6 @@ if (isset($_POST['usesubform']) && ! defined('PMA_MINIMUM_COMMON')) {
}
// end check if a subform is submitted
/**
* check timezone setting
* this could produce an E_WARNING - but only once,
* if not done here it will produce E_WARNING on every date/time function
*/
date_default_timezone_set(@date_default_timezone_get());
/******************************************************************************/
/* parsing configuration file LABEL_parsing_config_file */