For MediaWiki (recent comments | status changes | tags | authors | states | release notes | statistics)
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 ===