* Added $wgColorErrors: if set, database error messages will be highlighted when...
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 4 Apr 2006 05:53:21 +0000 (05:53 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 4 Apr 2006 05:53:21 +0000 (05:53 +0000)
RELEASE-NOTES
includes/Database.php
includes/DefaultSettings.php

index 287363d..06d8d1a 100644 (file)
@@ -737,6 +737,8 @@ fully support the editing toolbar, but was found to be too confusing.
 * (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 ===
index 57e68ea..b7e09da 100644 (file)
@@ -447,7 +447,7 @@ class Database {
         * @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 @@ class Database {
                                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 5748f7a..091aa96 100644 (file)
@@ -727,6 +727,13 @@ $wgDebugLogGroups       = array();
  */
 $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