--- DefaultHandler.php.orig	2009-09-24 09:37:15.000000000 +0100
+++ DefaultHandler.php	2009-09-24 12:12:30.000000000 +0100
@@ -122,7 +122,7 @@
 			$errtype = self::getPHPErrorDescription($errno);
 			
 			$error_hash[] = strtoupper(substr(md5($errno . $errmsg), 0, 4));
-			$error_hash[] = strtoupper(substr(md5($filename . $linenum), 0, 4));
+			$error_hash[] = self::locationHash($filename, $linenum, $debug_backtrace);
 			$error_hash = implode('/', $error_hash);
 			
 			$additional_environment  = "PHP Error Type:     $errtype\n";
@@ -159,11 +159,29 @@
 	public static function getExceptionHash(Exception $exception)
 	{
 		$error_hash[] = strtoupper(substr(md5($exception->getCode() . $exception->getMessage()), 0, 4));
-		$error_hash[] = strtoupper(substr(md5($exception->getFile() . $exception->getLine()), 0, 4));
+		$error_hash[] = self::locationHash($exception->getFile(), $exception->getLine(), $exception->getTrace());
 		$error_hash = implode('/', $error_hash);
 		return $error_hash;
 	}
 	
+	/**
+	 * Get a unique(ish) partial hash for location of an error or exception.
+	 * Hashing does uses the file paths in such away that an the same error on two
+	 * different evironments should gerenate the same hash.
+	 *
+	 * @return string              Hash in "YYYY" format
+	 */
+	private static function locationHash($filename, $linenum, $debug_backtrace)
+	{
+		$entropy = basename($filename) . $linenum;
+		foreach ($debug_backtrace as $trace_step) {
+			if (isset($trace_step['function'])) $entropy .= $trace_step['function'];
+			if (isset($trace_step['class']))    $entropy .= $trace_step['class'];
+			if (isset($trace_step['type']))     $entropy .= $trace_step['type'];	
+		}
+		return strtoupper(substr(md5($entropy), 0, 4));
+	}
+	
 	protected static function showOutput($errtype, $errmsg, $filename, $linenum, $backtrace, $termination_error)
 	{
 		if (self::getDisplayErrors() == false) {
