MediaWiki r13452 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r13451‎ | r13452 (on ViewVC)‎ | r13453 >
Date:05:53, 4 April 2006
Author:brion
Status:old
Tags:
Comment:
* Added $wgColorErrors: if set, database error messages will be highlighted when running command-line scripts in a Unix terminal.
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 13451)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 13452)
@@ -728,6 +728,13 @@
 $wgShowSQLErrors        = false;
 
 /**
+ * If true, some error messages will be colorized when running scripts on the
+ * command line; this can aid picking important things out when debugging.
+ * Ignored when running on Windows or when output is redirected to a file.
+ */
+$wgColorErrors          = true;
+
+/**
  * disable experimental dmoz-like category browsing. Output things like:
  * Encyclopedia > Music > Style of Music > Jazz
  */
Index: trunk/phase3/includes/Database.php
===================================================================
--- trunk/phase3/includes/Database.php	(revision 13451)
+++ trunk/phase3/includes/Database.php	(revision 13452)
@@ -447,7 +447,7 @@
 	 * @param bool $tempIgnore
 	 */
 	function reportQueryError( $error, $errno, $sql, $fname, $tempIgnore = false ) {
-		global $wgCommandLineMode, $wgFullyInitialised;
+		global $wgCommandLineMode, $wgFullyInitialised, $wgColorErrors;
 		# Ignore errors during error handling to avoid infinite recursion
 		$ignore = $this->ignoreErrors( true );
 		++$this->mErrorCount;
@@ -466,6 +466,10 @@
 				if ( !$wgCommandLineMode ) {
 					$message = nl2br( $message );
 				}
+				if( $wgCommandLineMode && $wgColorErrors && !wfIsWindows() && posix_isatty(1) ) {
+					$color = 31; // bright red!
+					$message = "\x1b[1;{$color}m{$message}\x1b[0m";
+				}
 				wfDebugDieBacktrace( $message );
 			} else {
 				// this calls wfAbruptExit()
Index: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES	(revision 13451)
+++ trunk/phase3/RELEASE-NOTES	(revision 13452)
@@ -737,6 +737,8 @@
 * (bug 5355) Include skin name and style JS settings in page source;
   fixes regression where Opera 6/7 and KHTML CSS fixes weren't applied
   when wikibits.js was moved up before user JS inclusion.
+* Added $wgColorErrors: if set, database error messages will be highlighted
+  when running command-line scripts in a Unix terminal.
 
 
 === Caveats ===

Status & tagging log

  • 01:58, 13 October 2010 ^demon (Talk | contribs) changed the status of r13452 [removed: new added: old]
Personal tools
Namespaces
Variants
Views
Actions
Site
Support
Download
Development
Communication
Toolbox