[Fusionforge-commits] r10411 - in trunk/src: common/include etc etc/local.d www/export

Thorsten Glaser mirabilos at libremir.placard.fr.eu.org
Tue Sep 7 11:34:02 CEST 2010


Author: mirabilos
Date: 2010-09-07 11:34:02 +0200 (Tue, 07 Sep 2010)
New Revision: 10411

Modified:
   trunk/src/common/include/extras-debug.php
   trunk/src/common/include/pre.php
   trunk/src/common/include/utils.php
   trunk/src/etc/config.ini-fhs
   trunk/src/etc/config.ini-opt
   trunk/src/etc/config.ini-usrlocal
   trunk/src/etc/local.d/24debug
   trunk/src/www/export/rssAboTask.php
Log:
?\226?\128?\162 add sysdebug_backtraces
?\226?\128?\162 let $ffErrors be always defined (simplifies *any* code that uses it)
?\226?\128?\162 since we don?\226?\128?\153t have Evolvis?\226?\128?\153 function sysdebug_off in FusionForge
  (might want to consider it though), fix www/export/rssAboTask.php
  (although we *have* a global $sysdebug_enable that could be used)


Modified: trunk/src/common/include/extras-debug.php
===================================================================
--- trunk/src/common/include/extras-debug.php	2010-09-05 08:35:47 UTC (rev 10410)
+++ trunk/src/common/include/extras-debug.php	2010-09-07 09:34:02 UTC (rev 10411)
@@ -1,6 +1,8 @@
 <?php
 
 $sysdebug_ignored = forge_get_config('sysdebug_ignored');
+if (!isset($ffErrors))
+	$ffErrors = array();
 
 // error handler function
 function ffErrorHandler($errno, $errstr, $errfile, $errline)
@@ -11,9 +13,6 @@
 		/* prepended @ to statement => ignore */
 		return false;
 
-	if (!isset($ffErrors))
-		$ffErrors = array();
-
 	$msg = "[$errno] $errstr ($errfile at $errline)";
 
 	// Display messages only once.
@@ -48,6 +47,11 @@
 			$type = 'unknown';
 			break;
 	}
+
+	if (forge_get_config('sysdebug_backtraces))
+		$msg .= "\n" .
+		    '<pre style="font-weight:normal; font-size:90%; color:#000066;">' .
+		    htmlentities(debug_string_backtrace()) . "</pre>";
 	
 	$ffErrors[] = array('type' => $type, 'message' => $msg);
 	/* Don't execute PHP internal error handler */
@@ -69,9 +73,6 @@
 	// this is, sadly, necessary (especially in ff-plugin-mediawiki)
 	$pre_tag = "<pre style=\"margin:0; padding:0; border:0;\">";
 
-	if (!isset($ffErrors))
-		$ffErrors = array();
-
 	$divstring = "\n\n" . '<script type="text/javascript"><!-- <![CDATA[
 		function toggle_ffErrors() {
 			var errorsblock = document.getElementById("ffErrorsBlock");

Modified: trunk/src/common/include/pre.php
===================================================================
--- trunk/src/common/include/pre.php	2010-09-05 08:35:47 UTC (rev 10410)
+++ trunk/src/common/include/pre.php	2010-09-07 09:34:02 UTC (rev 10411)
@@ -124,6 +124,8 @@
 forge_set_config_item_bool ('sysdebug_enable', 'core') ;
 forge_define_config_item ('sysdebug_phphandler', 'core', 'true') ;
 forge_set_config_item_bool ('sysdebug_phphandler', 'core') ;
+forge_define_config_item ('sysdebug_backtraces', 'core', 'false') ;
+forge_set_config_item_bool ('sysdebug_backtraces', 'core') ;
 forge_define_config_item ('sysdebug_ignored', 'core', 'false') ;
 forge_set_config_item_bool ('sysdebug_ignored', 'core') ;
 forge_define_config_item ('sysdebug_xmlstarlet', 'core', 'false') ;

Modified: trunk/src/common/include/utils.php
===================================================================
--- trunk/src/common/include/utils.php	2010-09-05 08:35:47 UTC (rev 10410)
+++ trunk/src/common/include/utils.php	2010-09-07 09:34:02 UTC (rev 10411)
@@ -1232,6 +1232,24 @@
 	}
 }
 
+/* get a backtrace as string */
+function debug_string_backtrace() {
+	ob_start();
+	debug_print_backtrace();
+	$trace = ob_get_contents();
+	ob_end_clean();
+
+	// Remove first item from backtrace as it's this function
+	// which is redundant.
+	$trace = preg_replace('/^#0\s+' . __FUNCTION__ . "[^\n]*\n/", '',
+	    $trace, 1);
+
+	// Renumber backtrace items.
+	$trace = preg_replace('/^#(\d+)/me', '\'#\' . ($1 - 1)', $trace);
+
+	return $trace;
+}
+
 // Local Variables:
 // mode: php
 // c-file-style: "bsd"

Modified: trunk/src/etc/config.ini-fhs
===================================================================
--- trunk/src/etc/config.ini-fhs	2010-09-05 08:35:47 UTC (rev 10410)
+++ trunk/src/etc/config.ini-fhs	2010-09-07 09:34:02 UTC (rev 10411)
@@ -25,6 +25,8 @@
 
 ; enable the PHP Error Handler (default if sysdebug_enable)
 sysdebug_phphandler = true
+; show backtraces for those (can be VERY long, esp. in gf-p-mediawiki)
+sysdebug_backtraces = false
 ; also report (display) ignored errors, e.g. from @call
 sysdebug_ignored = false
 

Modified: trunk/src/etc/config.ini-opt
===================================================================
--- trunk/src/etc/config.ini-opt	2010-09-05 08:35:47 UTC (rev 10410)
+++ trunk/src/etc/config.ini-opt	2010-09-07 09:34:02 UTC (rev 10411)
@@ -25,6 +25,8 @@
 
 ; enable the PHP Error Handler (default if sysdebug_enable)
 sysdebug_phphandler = true
+; show backtraces for those (can be VERY long, esp. in gf-p-mediawiki) 
+sysdebug_backtraces = false  
 ; also report (display) ignored errors, e.g. from @call
 sysdebug_ignored = false
 

Modified: trunk/src/etc/config.ini-usrlocal
===================================================================
--- trunk/src/etc/config.ini-usrlocal	2010-09-05 08:35:47 UTC (rev 10410)
+++ trunk/src/etc/config.ini-usrlocal	2010-09-07 09:34:02 UTC (rev 10411)
@@ -25,6 +25,8 @@
 
 ; enable the PHP Error Handler (default if sysdebug_enable)
 sysdebug_phphandler = true
+; show backtraces for those (can be VERY long, esp. in gf-p-mediawiki) 
+sysdebug_backtraces = false  
 ; also report (display) ignored errors, e.g. from @call
 sysdebug_ignored = false
 

Modified: trunk/src/etc/local.d/24debug
===================================================================
--- trunk/src/etc/local.d/24debug	2010-09-05 08:35:47 UTC (rev 10410)
+++ trunk/src/etc/local.d/24debug	2010-09-07 09:34:02 UTC (rev 10411)
@@ -17,6 +17,8 @@
 
 // enable the PHP Error Handler (default if sysdebug_enable)
 $sysdebug_phphandler = true;
+// show backtraces for those (can be VERY long, esp. in gf-p-mediawiki)
+$sysdebug_backtraces = false;
 // also report (display) ignored errors, e.g. from @call
 $sysdebug_ignored = false;
 

Modified: trunk/src/www/export/rssAboTask.php
===================================================================
--- trunk/src/www/export/rssAboTask.php	2010-09-05 08:35:47 UTC (rev 10410)
+++ trunk/src/www/export/rssAboTask.php	2010-09-07 09:34:02 UTC (rev 10411)
@@ -41,7 +41,7 @@
 if (!$tid)
 	$tid = util_path_info_last_numeric_component();
 if (!$tid) {
-	sysdebug_off("HTTP/1.0 404 Not Found");
+	header("HTTP/1.0 404 Not Found");
 	echo "You forgot to pass the tid.\n";
 	exit;
 }
@@ -49,7 +49,7 @@
 $tinfo = getGroupProjectIdGroupId($tid);
 
 if (!$tinfo) {
-	sysdebug_off("HTTP/1.0 404 Not Found");
+	header("HTTP/1.0 404 Not Found");
 	echo "There is no task with id ".$tid."!\n";
 	exit;
 }
@@ -123,7 +123,7 @@
 	/* It is possible to format a rss feed with cascading style sheet and xsl, but it does not work with
 	* Firefox version 3.6.6, so I did not make use of it. */
 
-	sysdebug_off('Content-Type: application/rss+xml; charset=utf-8');
+	header('Content-Type: application/rss+xml; charset=utf-8');
 
 	print'<?xml version="1.0" encoding="utf-8"?>';
 	print'<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "http://my.netscape.com/publish/formats/rss-0.91.dtd">';




More information about the Fusionforge-commits mailing list