From ca7d5863bf703057a9997cf69f9d883a0631b544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Sat, 3 May 2014 22:26:49 +0200 Subject: [PATCH] improved error check on shutdown --- application/core/ErrorHandler.php | 18 ++++++++++++++---- application/core/ManiaControl.php | 6 +----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/application/core/ErrorHandler.php b/application/core/ErrorHandler.php index 62b2d13d..a2d4bf24 100644 --- a/application/core/ErrorHandler.php +++ b/application/core/ErrorHandler.php @@ -111,9 +111,9 @@ class ErrorHandler { } /** - * Triggers a Debug Notice to the ManiaControl Website + * Trigger a Debug Notice to the ManiaControl Website * - * @param $message + * @param string $message */ public function triggerDebugNotice($message) { $this->handleError(self::MC_DEBUG_NOTICE, $message); @@ -122,10 +122,10 @@ class ErrorHandler { /** * Error Handler * - * @param int $errorNumber + * @param int $errorNumber * @param string $errorString * @param string $errorFile - * @param int $errorLine + * @param int $errorLine * @return bool */ public function handleError($errorNumber, $errorString, $errorFile = null, $errorLine = -1) { @@ -263,4 +263,14 @@ class ErrorHandler { private function shouldStopExecution($errorNumber) { return ($errorNumber === E_ERROR || $errorNumber === E_USER_ERROR || $errorNumber === E_FATAL); } + + /** + * Check if the Shutdown was caused by a Fatal Error and report it + */ + public function handleShutdown() { + $error = error_get_last(); + if ($error && ($error['type'] & E_FATAL)) { + $this->handleError($error['type'], $error['message'], $error['file'], $error['line']); + } + } } \ No newline at end of file diff --git a/application/core/ManiaControl.php b/application/core/ManiaControl.php index 4fe69c5c..4c579130 100644 --- a/application/core/ManiaControl.php +++ b/application/core/ManiaControl.php @@ -302,11 +302,7 @@ class ManiaControl implements CommandListener, TimerListener { } } - // Check and Trigger Fatal Errors - $error = error_get_last(); - if ($error && ($error['type'] & E_FATAL)) { - $this->errorHandler->handleError($error['type'], $error['message'], $error['file'], $error['line']); - } + $this->errorHandler->handleShutdown(); // Disable Garbage Collector $this->collectGarbage();