From 61453e964cb9223626b4232729674936443d2e9d 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'.) --- 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 acefbb4b0..b573f432d 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 edf708b16..da53562d1 100644 --- a/lib/SimpleSAML/Error/Exception.php +++ b/lib/SimpleSAML/Error/Exception.php @@ -201,18 +201,9 @@ class Exception extends \Exception */ protected function logBacktrace(int $level = Logger::DEBUG): void { - // 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