Clean up \wcf\system\exception\*
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 29 Sep 2015 20:55:16 +0000 (22:55 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 1 Dec 2015 21:15:48 +0000 (22:15 +0100)
wcfsetup/install/files/lib/action/AJAXInvokeAction.class.php
wcfsetup/install/files/lib/system/exception/IPrintableException.class.php
wcfsetup/install/files/lib/system/exception/LoggedException.class.php
wcfsetup/install/files/lib/system/exception/NamedUserException.class.php
wcfsetup/install/files/lib/system/exception/SystemException.class.php

index c1a1f848e758e9942ecb8d1dc78018eb677f2aa4..a0041c72c98c68190e3efd979d82347d46286f0c 100644 (file)
@@ -157,7 +157,8 @@ class AJAXInvokeAction extends AbstractSecureAction {
                if ($this->inDebugMode) {
                        throw $e;
                }
-               
+               // TODO: This needs to be updated to the new exception handling code.
+               throw new \Exception('TODO: AJAXInvokeAction::throwException()');
                if ($e instanceof InvalidSecurityTokenException) {
                        throw new AJAXException(WCF::getLanguage()->get('wcf.ajax.error.sessionExpired'), AJAXException::SESSION_EXPIRED, $e->getTraceAsString());
                }
index bc0e745c88243f24c0ac41222bfbb684408e3c63..11a20b40996a04209fef9671c2987c7110e1b767 100644 (file)
@@ -10,6 +10,7 @@ namespace wcf\system\exception;
  * @package    com.woltlab.wcf
  * @subpackage system.exception
  * @category   Community Framework
+ * @deprecated 2.2 - Fatal Exceptions are printed automatically, if you need a well styled page use: NamedUserException
  */
 interface IPrintableException {
        /**
index 022fb2d1b3a4895ff3d924f8a3728e47a98b0c4c..0fcf16397323e7502fbffd06852ef583803748b7 100644 (file)
@@ -14,33 +14,9 @@ use wcf\util\StringUtil;
  * @package    com.woltlab.wcf
  * @subpackage system.exception
  * @category   Community Framework
+ * @deprecated 2.2 - Fatal Exceptions are logged automatically.
  */
 class LoggedException extends \Exception {
-       /**
-        * exception id
-        * @var string
-        */
-       protected $exceptionID = '';
-       
-       /**
-        * ignore disabled debug mode
-        * @var boolean
-        */
-       protected $ignoreDebugMode = false;
-       
-       /**
-        * @see \Exception::getMessage()
-        */
-       public function _getMessage() {
-               // suppresses the original error message
-               if (!WCF::debugModeIsEnabled() && !$this->ignoreDebugMode) {
-                       return 'An error occured. Sorry.';
-               }
-               
-               $e = ($this->getPrevious() ?: $this);
-               return $e->getMessage();
-       }
-       
        /**
         * Returns exception id
         * 
@@ -48,65 +24,18 @@ class LoggedException extends \Exception {
         */
        public function getExceptionID() {
                if (empty($this->exceptionID)) {
-                       $this->logError();
-               }
-               
-               return $this->exceptionID;
-       }
-       
-       /**
-        * Removes database password from stack trace.
-        * @see \Exception::getTraceAsString()
-        */
-       public function __getTraceAsString() {
-               $e = ($this->getPrevious() ?: $this);
-               $string = preg_replace('/Database->__construct\(.*\)/', 'Database->__construct(...)', $e->getTraceAsString());
-               return $string;
-       }
-       
-       /**
-        * Writes an error to log file.
-        */
-       protected function logError() {
-               if (!empty($this->exceptionID)) {
-                       return;
-               }
-               
-               $logFile = WCF_DIR . 'log/' . gmdate('Y-m-d', TIME_NOW) . '.txt';
-               
-               // try to create file
-               @touch($logFile);
-               
-               // validate if file exists and is accessible for us
-               if (!file_exists($logFile) || !is_writable($logFile)) {
-                       /*
-                               We cannot recover if we reached this point, the server admin
-                               is urged to fix his pretty much broken configuration.
+                       try {
+                               \wcf\functions\exception\logThrowable($this);
+                       }
+                       catch (\Exception $e) {
+                               
+                       }
+                       catch (\Throwable $e) {
                                
-                               GLaDOS: Look at you, sailing through the air majestically, like an eagle... piloting a blimp.
-                       */
-                       return;
+                       }
+                       $this->exceptionID = '*MAYDAY*';
                }
                
-               $e = ($this->getPrevious() ?: $this);
-               
-               // don't forget to update ExceptionLogViewPage, when changing the log file format
-               $message = gmdate('r', TIME_NOW)."\n".
-                       'Message: '.$e->getMessage()."\n".
-                       'File: '.$e->getFile().' ('.$e->getLine().")\n".
-                       'PHP version: '.phpversion()."\n".
-                       'WCF version: '.WCF_VERSION."\n".
-                       'Request URI: '.(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '')."\n".
-                       'Referrer: '.(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '')."\n".
-                       'User-Agent: '.(isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '')."\n".
-                       'Information: '.JSON::encode($this->information)."\n".
-                       "Stacktrace: \n  ".implode("\n  ", explode("\n", $this->__getTraceAsString()))."\n";
-               
-               // calculate Exception-ID
-               $this->exceptionID = StringUtil::getHash($message);
-               $message = "<<<<<<<<".$this->exceptionID."<<<<\n".$message."<<<<\n\n";
-               
-               // append
-               @file_put_contents($logFile, $message, FILE_APPEND);
+               return $this->exceptionID;
        }
 }
index a2676fade34bb45f6d821732742af8a67c8e3f76..0ae316833e2c42080e63f861acf289d3e0dd7942 100644 (file)
@@ -13,11 +13,6 @@ use wcf\system\WCF;
  * @category   Community Framework
  */
 class NamedUserException extends UserException {
-       /**
-        * @see \wcf\system\exception\LoggedException::$ignoreDebugMode
-        */
-       protected $ignoreDebugMode = true;
-       
        /**
         * Shows a styled page with the given error message.
         */
index ef1e4458b9d4b68b3c5d43ef37bcfd6870d870a9..4c19625f2e4a118ac66f85e9701f0087d1c5285a 100644 (file)
@@ -58,7 +58,5 @@ class SystemException extends LoggedException {
        /**
         * @see \wcf\system\exception\IPrintableException::show()
         */
-       public function show() {
-               
-       }
+       public function show() { }
 }