From 6601e8c2b74f0ebd4e224713e7feadbe9b09d330 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 27 Oct 2016 20:16:56 +0000 Subject: [PATCH 1/2] Prevent a memory Access Violation when the database isn't connected --- include/text.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/text.php b/include/text.php index 4b2a4a940..1b3050f5f 100644 --- a/include/text.php +++ b/include/text.php @@ -703,10 +703,6 @@ function logger($msg, $level = 0) { global $db; global $LOGGER_LEVELS; - $debugging = get_config('system','debugging'); - $logfile = get_config('system','logfile'); - $loglevel = intval(get_config('system','loglevel')); - // turn off logger in install mode if ( $a->module == 'install' @@ -718,6 +714,10 @@ function logger($msg, $level = 0) { return; } + $debugging = get_config('system','debugging'); + $logfile = get_config('system','logfile'); + $loglevel = intval(get_config('system','loglevel')); + if (count($LOGGER_LEVELS) == 0) { foreach (get_defined_constants() as $k => $v) { if (substr($k, 0, 7) == "LOGGER_") { From bebcbd04d309458da026b45490881c0434d496b3 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 28 Oct 2016 04:29:22 +0000 Subject: [PATCH 2/2] We should check values after we fetched them :-) --- include/text.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/include/text.php b/include/text.php index 1b3050f5f..5c9202c58 100644 --- a/include/text.php +++ b/include/text.php @@ -707,9 +707,6 @@ function logger($msg, $level = 0) { if ( $a->module == 'install' || ! ($db && $db->connected) - || ! $debugging - || ! $logfile - || $level > $loglevel ) { return; } @@ -718,6 +715,14 @@ function logger($msg, $level = 0) { $logfile = get_config('system','logfile'); $loglevel = intval(get_config('system','loglevel')); + if ( + ! $debugging + || ! $logfile + || $level > $loglevel + ) { + return; + } + if (count($LOGGER_LEVELS) == 0) { foreach (get_defined_constants() as $k => $v) { if (substr($k, 0, 7) == "LOGGER_") {