diff --git a/application/core/ErrorHandler.php b/application/core/ErrorHandler.php index f6adf326..645925a5 100644 --- a/application/core/ErrorHandler.php +++ b/application/core/ErrorHandler.php @@ -38,15 +38,16 @@ class ErrorHandler { * @param \Exception $ex */ public function exceptionHandler(\Exception $ex) { - $message = "[ManiaControl EXCEPTION]: {$ex->getMessage()}" . PHP_EOL; - $message .= "Class: " . get_class($ex) . PHP_EOL; - $message .= "Trace: {$ex->getTraceAsString()}" . PHP_EOL; - logMessage($message); + $message = "[ManiaControl EXCEPTION]: {$ex->getMessage()}"; + $traceMessage = 'Class: ' . get_class($ex) . PHP_EOL; + $traceMessage .= 'Trace:' . PHP_EOL . $ex->getTraceAsString(); + logMessage($message . PHP_EOL . $traceMessage); if ($this->reportErrors) { $error = array(); $error["Type"] = "Exception"; $error["Message"] = $message; + $error["Backtrace"] = $traceMessage; $error['OperatingSystem'] = php_uname(); $error['PHPVersion'] = phpversion(); @@ -102,13 +103,15 @@ class ErrorHandler { // Log error $errorTag = $this->getErrorTag($errorNumber); - $message = "{$errorTag}: {$errorString} in File '{$errorFile}' on Line {$errorLine}!"; - logMessage($message); + $message = $errorTag . ': ' . $errorString; + $traceMessage = $this->parseBackTrace(debug_backtrace()); + logMessage($message . PHP_EOL . $traceMessage); if ($this->reportErrors && $errorNumber != E_USER_ERROR && $errorNumber != E_USER_WARNING && $errorNumber != E_USER_NOTICE) { $error = array(); $error["Type"] = "Error"; $error["Message"] = $message; + $error["Backtrace"] = $traceMessage; $error['OperatingSystem'] = php_uname(); $error['PHPVersion'] = phpversion(); @@ -200,4 +203,36 @@ class ErrorHandler { } return "[PHP {$errorLevel}]"; } + + /** + * Parse the Debug Backtrace into a String for the Error Report + * + * return string + */ + private function parseBackTrace(array $backtrace) { + $traceString = 'Trace:'; + $stepCount = 0; + foreach ($backtrace as $traceStep) { + $traceString .= PHP_EOL . '#' . $stepCount . ': '; + if (isset($traceStep['class'])) { + $traceString .= $traceStep['class']; + } + if (isset($traceStep['type'])) { + $traceString .= $traceStep['type']; + } + if (isset($traceStep['function'])) { + $traceString .= $traceStep['function']; + } + if (isset($traceStep['file'])) { + $traceString .= ' in File '; + $traceString .= $traceStep['file']; + } + if (isset($traceStep['line'])) { + $traceString .= ' on Line '; + $traceString .= $traceStep['line']; + } + $stepCount++; + } + return $traceString; + } } \ No newline at end of file diff --git a/application/core/ManiaControl.php b/application/core/ManiaControl.php index e5cbcfaf..4a94d467 100644 --- a/application/core/ManiaControl.php +++ b/application/core/ManiaControl.php @@ -127,7 +127,6 @@ class ManiaControl implements CommandListener, TimerListener { $this->commandManager->registerCommandListener('shutdown', $this, 'command_Shutdown', true); } - /** * Print a message to console and log * diff --git a/application/core/Maps/MapQueue.php b/application/core/Maps/MapQueue.php index 38edd2b0..8cc6219e 100644 --- a/application/core/Maps/MapQueue.php +++ b/application/core/Maps/MapQueue.php @@ -214,8 +214,8 @@ class MapQueue implements CallbackListener, CommandListener { public function getQueuedMapsRanking() { $i = 1; $queuedMaps = array(); - foreach($this->queuedMaps as $map) { - $map = $map[1]; + foreach($this->queuedMaps as $queuedMap) { + $map = $queuedMap[1]; $queuedMaps[$map->uid] = $i; $i++; } diff --git a/application/plugins/Dedimania/Dedimania.php b/application/plugins/Dedimania/Dedimania.php index dcc39fef..5860d4fc 100644 --- a/application/plugins/Dedimania/Dedimania.php +++ b/application/plugins/Dedimania/Dedimania.php @@ -844,7 +844,7 @@ class Dedimania implements CallbackListener, TimerListener, Plugin { } /** - * Encodes the given xml rpc method and params + * Encode the given xml rpc method and params * * @param string $method * @param array $params @@ -856,7 +856,7 @@ class Dedimania implements CallbackListener, TimerListener, Plugin { } /** - * Handles xml rpc fault + * Handle xml rpc fault * * @param $fault * @param $method @@ -865,10 +865,14 @@ class Dedimania implements CallbackListener, TimerListener, Plugin { trigger_error('XmlRpc Fault on ' . $method . ': ' . $fault['faultString'] . ' (' . $fault['faultCode'] . ')'); } - + /** + * Build Manialink + * + * @return \FML\ManiaLink + */ private function buildManialink() { if (!$this->dedimaniaData->records) { - return ''; + return null; } $records = $this->dedimaniaData->records; diff --git a/application/plugins/WidgetPlugin.php b/application/plugins/WidgetPlugin.php index 0e2d28d8..6dde4d47 100644 --- a/application/plugins/WidgetPlugin.php +++ b/application/plugins/WidgetPlugin.php @@ -448,7 +448,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { */ $requester = null; // if the nextmap is not a queued map, get it from map info - if ($queuedMap == null) { + if (!$queuedMap) { $map = $this->maniaControl->client->getNextMapInfo(); $name = Formatter::stripDirtyCodes($map->name); $author = $map->author;