DB error log
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index 7e4d911..0ae7fdc 100644 (file)
@@ -40,8 +40,8 @@ if( !function_exists('is_a') ) {
        # Exists in PHP 4.2.0+
        function is_a( $object, $class_name ) {
                return
-                       (strcasecmp( get_class( $object, $class_name ) == 0) ||
-                        is_subclass_of( $object, $class_name ) );
+                       (strcasecmp( get_class( $object ), $class_name ) == 0) ||
+                        is_subclass_of( $object, $class_name );
        }
 }
 
@@ -227,6 +227,15 @@ function wfDebug( $text, $logonly = false )
        }
 }
 
+# Log for database errors
+function wfLogDBError( $text ) {
+       global $wgDBerrorLog;
+       if ( $wgDBerrorLog ) {
+               $text = date("D M j G:i:s T Y") . "\t$text";
+               error_log( $text, 3, $wgDBerrorLog );
+       }
+}
+
 function logProfilingData()
 {
        global $wgRequestTime, $wgDebugLogFile;
@@ -370,15 +379,31 @@ function wfAbruptExit(){
 }
 
 function wfDebugDieBacktrace( $msg = '' ) {
+       global $wgCommandLineMode;
+
        if ( function_exists( 'debug_backtrace' ) ) {
-               $msg .= "\n<p>Backtrace:</p>\n<ul>\n";
+               if ( $wgCommandLineMode ) {
+                       $msg .= "\nBacktrace:\n";
+               } else {
+                       $msg .= "\n<p>Backtrace:</p>\n<ul>\n";
+               }
                $backtrace = debug_backtrace();
                foreach( $backtrace as $call ) {
                        $f = explode( DIRECTORY_SEPARATOR, $call['file'] );
                        $file = $f[count($f)-1];
-                       $msg .= '<li>' . $file . " line " . $call['line'] . ', in ';
+                       if ( $wgCommandLineMode ) {
+                               $msg .= "$file line {$call['line']}, in ";
+                       } else {
+                               $msg .= '<li>' . $file . " line " . $call['line'] . ', in ';
+                       }
                        if( !empty( $call['class'] ) ) $msg .= $call['class'] . '::';
-                       $msg .= $call['function'] . "()</li>\n";
+                       $msg .= $call['function'] . "()";
+                       
+                       if ( $wgCommandLineMode ) {
+                               $msg .= "\n";
+                       } else {
+                               $msg .= "</li>\n";
+                       }
                }
         }
         die( $msg );