From c3d060c97366c8484c36497a16db05c18377652d Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Mon, 15 Dec 2014 10:13:10 +0100 Subject: [PATCH] Move logger init to seperate funtion so that its PHP 5.3+ syntax does not fatally break the serendipity_config.inc.php parsing on PHP5 5.3-. Also create a reasonable error message when running on an old version. --- include/functions.inc.php | 18 ++++++++++++++++++ serendipity_config.inc.php | 17 ++++++++--------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/include/functions.inc.php b/include/functions.inc.php index a0caf9fb..fca30d69 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -1205,5 +1205,23 @@ function serendipity_db_time() { return $ts; } +/* Inits the logger. + * @return null + */ +function serendipity_initLog() { + global $serendipity; + + if (isset($serendipity['logLevel']) && $serendipity['logLevel'] !== 'Off') { + if ($serendipity['logLevel'] == 'debug') { + $log_level = Psr\Log\LogLevel::DEBUG; + } else { + $log_level = Psr\Log\LogLevel::ERROR; + } + + $serendipity['logger'] = new Katzgrau\KLogger\Logger($serendipity['serendipityPath'] . '/templates_c/logs', $log_level); + } +} + + define("serendipity_FUNCTIONS_LOADED", true); /* vim: set sts=4 ts=4 expandtab : */ diff --git a/serendipity_config.inc.php b/serendipity_config.inc.php index 7c7a4ffd..0c1ee36a 100644 --- a/serendipity_config.inc.php +++ b/serendipity_config.inc.php @@ -184,6 +184,13 @@ $serendipity['charsets'] = array( @define('VIEWMODE_THREADED', 'threaded'); @define('VIEWMODE_LINEAR', 'linear'); +if (!version_compare(phpversion(), '5.3', '>=')) { + $serendipity['lang'] = 'en'; + include(S9Y_INCLUDE_PATH . 'include/lang.inc.php'); + serendipity_die(sprintf(SERENDIPITY_PHPVERSION_FAIL, phpversion(), '5.3')); +} + + /* * Kill the script if we are not installed, and not inside the installer */ @@ -310,15 +317,7 @@ if (defined('USE_MEMSNAP')) { serendipity_load_configuration(); $serendipity['lang'] = serendipity_getSessionLanguage(); -if (isset($serendipity['logLevel']) && $serendipity['logLevel'] !== 'Off') { - if ($serendipity['logLevel'] == 'debug') { - $log_level = Psr\Log\LogLevel::DEBUG; - } else { - $log_level = Psr\Log\LogLevel::ERROR; - } - - $serendipity['logger'] = new Katzgrau\KLogger\Logger($serendipity['serendipityPath'] . '/templates_c/logs', $log_level); -} +serendipity_initLog(); if ( (isset($serendipity['autodetect_baseURL']) && serendipity_db_bool($serendipity['autodetect_baseURL'])) || (isset($serendipity['embed']) && serendipity_db_bool($serendipity['embed'])) ) {