Prevent non-critical exceptions in the ACP to include a stacktrace
authorAlexander Ebert <ebert@woltlab.com>
Fri, 27 Jun 2014 23:17:27 +0000 (01:17 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 27 Jun 2014 23:17:27 +0000 (01:17 +0200)
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
wcfsetup/install/files/lib/system/exception/AJAXException.class.php

index 28cd574b1caa12ef016e6c214a366c67fe6a9c41..7c0008d30d00775df8d316f3b6bb0d0d0a57eb7d 100644 (file)
@@ -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) {
index 854b41f9053c5cc79b7f3239bcbe471ad8b6d186..6d9c2762a2697a7b60d452319e38a04b4278d23f 100644 (file)
@@ -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);
                }