From 1037d65fd61e4ef37aa19d016f659397027aea6b Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sat, 28 Jun 2014 01:17:27 +0200 Subject: [PATCH] Prevent non-critical exceptions in the ACP to include a stacktrace For example throwing a PermissionDeniedException would cause a stacktrace to be printed, even though it is not meant to be an error in terms of a critical exception. --- wcfsetup/install/files/lib/system/WCF.class.php | 5 +++-- .../files/lib/system/exception/AJAXException.class.php | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/lib/system/WCF.class.php b/wcfsetup/install/files/lib/system/WCF.class.php index 28cd574b1c..7c0008d30d 100644 --- a/wcfsetup/install/files/lib/system/WCF.class.php +++ b/wcfsetup/install/files/lib/system/WCF.class.php @@ -676,11 +676,12 @@ class WCF { /** * Returns true if the debug mode is enabled, otherwise false. * + * @param boolean $ignoreACP * @return boolean */ - public static function debugModeIsEnabled() { + public static function debugModeIsEnabled($ignoreACP = false) { // ACP override - if (self::$overrideDebugMode) { + if (!$ignoreACP && self::$overrideDebugMode) { return true; } else if (defined('ENABLE_DEBUG_MODE') && ENABLE_DEBUG_MODE) { diff --git a/wcfsetup/install/files/lib/system/exception/AJAXException.class.php b/wcfsetup/install/files/lib/system/exception/AJAXException.class.php index 854b41f905..6d9c2762a2 100644 --- a/wcfsetup/install/files/lib/system/exception/AJAXException.class.php +++ b/wcfsetup/install/files/lib/system/exception/AJAXException.class.php @@ -69,7 +69,10 @@ class AJAXException extends LoggedException { 'returnValues' => $returnValues ); - if (WCF::debugModeIsEnabled()) { + // include a stacktrace if: + // - debug mode is enabled + // - within ACP and a SystemException was thrown + if (WCF::debugModeIsEnabled(false) || WCF::debugModeIsEnabled() && self::INTERNAL_ERROR) { $responseData['stacktrace'] = nl2br($stacktrace); } -- 2.20.1