From d9fef488af150107b753b3c30e15ab5bf6d9da38 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 26 Jul 2011 17:48:17 +0200 Subject: [PATCH 1/2] [ticket/9079] Display backtrace on all E_USER_ERROR errors, not only SQL errors PHPBB3-9079 --- phpBB/includes/db/dbal.php | 5 ----- phpBB/includes/functions.php | 7 +++++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php index b4c1a72e1c..230c9c8ed7 100644 --- a/phpBB/includes/db/dbal.php +++ b/phpBB/includes/db/dbal.php @@ -662,12 +662,7 @@ class dbal // The DEBUG_EXTRA constant is for development only! if ((isset($auth) && $auth->acl_get('a_')) || defined('IN_INSTALL') || defined('DEBUG_EXTRA')) { - // Print out a nice backtrace... - $backtrace = get_backtrace(); - $message .= ($sql) ? '

SQL

' . htmlspecialchars($sql) : ''; - $message .= ($backtrace) ? '

BACKTRACE
' . $backtrace : ''; - $message .= '
'; } else { diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 852fc683f2..f625f70c0f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3853,6 +3853,13 @@ function msg_handler($errno, $msg_text, $errfile, $errline) } } + if (defined('IN_INSTALL') || defined('DEBUG_EXTRA') || isset($auth) && $auth->acl_get('a_')) + { + $backtrace = get_backtrace(); + $msg_text .= ($backtrace) ? '

BACKTRACE
' . $backtrace : ''; + $msg_text .= '
'; + } + if ((defined('DEBUG') || defined('IN_CRON') || defined('IMAGE_OUTPUT')) && isset($db)) { // let's avoid loops From b6999237f456443b0b325f2ebee1f990ee7f5116 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sat, 24 Dec 2011 01:24:09 -0500 Subject: [PATCH 2/2] [ticket/9079] Always log backtrace to error log when logging errors. PHPBB3-9079 --- phpBB/includes/functions.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index f625f70c0f..1eefaee651 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3853,18 +3853,23 @@ function msg_handler($errno, $msg_text, $errfile, $errline) } } + $log_text = $msg_text; + $backtrace = get_backtrace(); + if ($backtrace) + { + $log_text .= '

BACKTRACE
' . $backtrace; + } + if (defined('IN_INSTALL') || defined('DEBUG_EXTRA') || isset($auth) && $auth->acl_get('a_')) { - $backtrace = get_backtrace(); - $msg_text .= ($backtrace) ? '

BACKTRACE
' . $backtrace : ''; - $msg_text .= '
'; + $msg_text = $log_text; } if ((defined('DEBUG') || defined('IN_CRON') || defined('IMAGE_OUTPUT')) && isset($db)) { // let's avoid loops $db->sql_return_on_error(true); - add_log('critical', 'LOG_GENERAL_ERROR', $msg_title, $msg_text); + add_log('critical', 'LOG_GENERAL_ERROR', $msg_title, $log_text); $db->sql_return_on_error(false); }