View Issue Details

IDProjectCategoryView StatusLast Update
272Exception_DefaultHandlerAllpublic17 Jan 2010 19:36
Reportermrosenquist Assigned Totimj  
PrioritynormalSeveritytweakReproducibilityhave not tried
Status closedResolutionfixed 
Product Version0.7.0 
Target Version0.8.0Fixed in Version0.8.0 
Summary272: Modify the error-hash to make it where error/exceptions are generated, without making it path specific
DescriptionModify the error-hash to make it where error/exceptions are generated, without making it path specific
TagsNo tags attached.
Attached Files
DefaultHandler.php.patch (1,915 bytes)   
--- 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) {
DefaultHandler.php.patch (1,915 bytes)   

Activities

mrosenquist

25 Sep 2009 07:30

reporter   ~277

I might be an idea to make this has different to the old hash so it can be detected
recomend the second part being 5chars

timj

12 Oct 2009 14:17

administrator   ~290

Fixed in SVN r1939

Issue History

Date Modified Username Field Change
24 Sep 2009 13:08 mrosenquist New Issue
24 Sep 2009 13:08 mrosenquist File Added: DefaultHandler.php.patch
25 Sep 2009 07:30 mrosenquist Note Added: 277
2 Oct 2009 10:22 timj Target Version => 0.8.0
12 Oct 2009 14:17 timj Note Added: 290
12 Oct 2009 14:17 timj Status new => resolved
12 Oct 2009 14:17 timj Fixed in Version => 0.8.0
12 Oct 2009 14:17 timj Resolution open => fixed
12 Oct 2009 14:17 timj Assigned To => timj
17 Jan 2010 19:36 timj Status resolved => closed
14 Oct 2011 20:47 timj Category => All