From a167b7c29ad8e02852d92ac218c6d82a6ededaf1 Mon Sep 17 00:00:00 2001 From: Thijs Kinkhorst <thijs@kinkhorst.com> Date: Fri, 7 Aug 2020 18:39:13 +0000 Subject: [PATCH] Improve backtraces configuration. The previous situation was confusing with various contradicting (staments of) defaults, mixed with old style and new style configuration. Simplify by deciding that having backtraces is so useful that it is the defaut, both old and new style configurations. (It was already default on in the config template, which seems 'canonical'.) (cherry picked from commit 61453e964cb9223626b4232729674936443d2e9d) --- config-templates/config.php | 5 ++--- lib/SimpleSAML/Error/Exception.php | 15 +++------------ 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/config-templates/config.php b/config-templates/config.php index d46c1ffc6..170bbe960 100644 --- a/config-templates/config.php +++ b/config-templates/config.php @@ -237,9 +237,8 @@ $config = [ * SAML messages will be logged, including plaintext versions of encrypted * messages. * - * - 'backtraces': this action controls the logging of error backtraces. If you - * want to log backtraces so that you can debug any possible errors happening in - * SimpleSAMLphp, enable this action (add it to the array or set it to true). + * - 'backtraces': this action controls the logging of error backtraces so you + * can debug any possible errors happening in SimpleSAMLphp. * * - 'validatexml': this action allows you to validate SAML documents against all * the relevant XML schemas. SAML 1.1 messages or SAML metadata parsed with diff --git a/lib/SimpleSAML/Error/Exception.php b/lib/SimpleSAML/Error/Exception.php index b0b7b8809..df7ed1a52 100644 --- a/lib/SimpleSAML/Error/Exception.php +++ b/lib/SimpleSAML/Error/Exception.php @@ -204,18 +204,9 @@ class Exception extends \Exception */ protected function logBacktrace($level = Logger::DEBUG) { - // see if debugging is enabled for backtraces - $debug = Configuration::getInstance()->getArrayize('debug', ['backtraces' => false]); - - if ( - !(in_array('backtraces', $debug, true) // implicitly enabled - || (array_key_exists('backtraces', $debug) - && $debug['backtraces'] === true) - // explicitly set - // TODO: deprecate the old style and remove it in 2.0 - || (array_key_exists(0, $debug) - && $debug[0] === true)) // old style 'debug' configuration option - ) { + // Do nothing if backtraces have been disabled in config. + $debug = Configuration::getInstance()->getArrayize('debug', ['backtraces' => true]); + if (array_key_exists('backtraces', $debug) && $debug['backtraces'] === false) { return; } -- GitLab