improved error analysing regarding source class
This commit is contained in:
		| @@ -206,12 +206,16 @@ class ErrorHandler { | |||||||
| 			return false; | 			return false; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$errorTag    = $this->getErrorTag($errorNumber); | 		$errorTag         = $this->getErrorTag($errorNumber); | ||||||
| 		$sourceClass = null; | 		$traceSourceClass = null; | ||||||
|  |  | ||||||
| 		$message     = $errorTag . ': ' . $errorString; | 		$message     = $errorTag . ': ' . $errorString; | ||||||
| 		$fileLine    = $errorFile . ': ' . $errorLine; | 		$fileLine    = $errorFile . ': ' . $errorLine; | ||||||
| 		$traceString = $this->parseBackTrace(debug_backtrace(), $sourceClass); | 		$traceString = $this->parseBackTrace(array_slice(debug_backtrace(), 1), $traceSourceClass); | ||||||
|  | 		$sourceClass = $this->getSourceClass($errorFile); | ||||||
|  | 		if (!$sourceClass) { | ||||||
|  | 			$sourceClass = $traceSourceClass; | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		$logMessage = $message . PHP_EOL . 'File&Line: ' . $fileLine . PHP_EOL . 'Trace: ' . $traceString; | 		$logMessage = $message . PHP_EOL . 'File&Line: ' . $fileLine . PHP_EOL . 'Trace: ' . $traceString; | ||||||
| 		$this->maniaControl->log($logMessage); | 		$this->maniaControl->log($logMessage); | ||||||
| @@ -289,6 +293,27 @@ class ErrorHandler { | |||||||
| 		return "[PHP ERROR '{$errorLevel}']"; | 		return "[PHP ERROR '{$errorLevel}']"; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * Get the Source Class via the Error File | ||||||
|  | 	 * | ||||||
|  | 	 * @param string $errorFile | ||||||
|  | 	 * @return string | ||||||
|  | 	 */ | ||||||
|  | 	private function getSourceClass($errorFile) { | ||||||
|  | 		if (!$errorFile) { | ||||||
|  | 			return null; | ||||||
|  | 		} | ||||||
|  | 		$filePath  = substr($errorFile, strlen(ManiaControlDir)); | ||||||
|  | 		$filePath  = str_replace('plugins' . DIRECTORY_SEPARATOR, '', $filePath); | ||||||
|  | 		$filePath  = str_replace('core' . DIRECTORY_SEPARATOR, '', $filePath); | ||||||
|  | 		$className = str_replace('.php', '', $filePath); | ||||||
|  | 		$className = str_replace(DIRECTORY_SEPARATOR, '\\', $className); | ||||||
|  | 		if (!class_exists($className, false)) { | ||||||
|  | 			return null; | ||||||
|  | 		} | ||||||
|  | 		return $className; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| 	 * Check if the given Error Number is a User Error | 	 * Check if the given Error Number is a User Error | ||||||
| 	 * | 	 * | ||||||
| @@ -314,7 +339,7 @@ class ErrorHandler { | |||||||
| 	 */ | 	 */ | ||||||
| 	public function handleShutdown() { | 	public function handleShutdown() { | ||||||
| 		$error = error_get_last(); | 		$error = error_get_last(); | ||||||
| 		if ($error && ($error['type'] & E_FATAL)) { | 		if ($error) { | ||||||
| 			$this->handleError($error['type'], $error['message'], $error['file'], $error['line']); | 			$this->handleError($error['type'], $error['message'], $error['file'], $error['line']); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user