From dffa9f06b7d307ff6d00308ee2d8a2847b696eca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 4 Sep 2017 17:34:04 +0200 Subject: [PATCH] Move PHP confguration to Core class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue #11731 Signed-off-by: Michal Čihař --- libraries/classes/Core.php | 28 ++++++++++++++++++++++++++++ libraries/common.inc.php | 18 ++---------------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/libraries/classes/Core.php b/libraries/classes/Core.php index 215167099b..1d2a8d473b 100644 --- a/libraries/classes/Core.php +++ b/libraries/classes/Core.php @@ -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()); + } } diff --git a/libraries/common.inc.php b/libraries/common.inc.php index 5e007736b4..5a14bd7c89 100644 --- a/libraries/common.inc.php +++ b/libraries/common.inc.php @@ -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 */