* Fix notice errors in wfDebugDieBacktrace() in XML callbacks
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 18 Jan 2005 10:24:33 +0000 (10:24 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 18 Jan 2005 10:24:33 +0000 (10:24 +0000)
* Suppress notice error on bogus timestamp input (returns epoch as before)

includes/GlobalFunctions.php

index abe9f36..143bb96 100644 (file)
@@ -475,12 +475,21 @@ function wfDebugDieBacktrace( $msg = '' ) {
                }
                $backtrace = debug_backtrace();
                foreach( $backtrace as $call ) {
-                       $f = explode( DIRECTORY_SEPARATOR, $call['file'] );
-                       $file = $f[count($f)-1];
+                       if( isset( $call['file'] ) ) {
+                               $f = explode( DIRECTORY_SEPARATOR, $call['file'] );
+                               $file = $f[count($f)-1];
+                       } else {
+                               $file = '-';
+                       }
+                       if( isset( $call['line'] ) ) {
+                               $line = $call['line'];
+                       } else {
+                               $line = '-';
+                       }
                        if ( $wgCommandLineMode ) {
-                               $msg .= "$file line {$call['line']} calls ";
+                               $msg .= "$file line $line calls ";
                        } else {
-                               $msg .= '<li>' . $file . ' line ' . $call['line'] . ' calls ';
+                               $msg .= '<li>' . $file . ' line ' . $line . ' calls ';
                        }
                        if( !empty( $call['class'] ) ) $msg .= $call['class'] . '::';
                        $msg .= $call['function'] . '()';
@@ -1017,6 +1026,10 @@ function wfTimestamp($outputtype=TS_UNIX,$ts=0) {
        } elseif (preg_match("/^(\d{1,13})$/",$ts,$datearray)) {
                # TS_UNIX
                $uts=$ts;
+       } else {
+               # Bogus value; fall back to the epoch...
+               wfDebug("wfTimestamp() given bogus time value.\n");
+               $uts = 0;
        }
 
        if ($ts==0)
@@ -1031,7 +1044,7 @@ function wfTimestamp($outputtype=TS_UNIX,$ts=0) {
        case TS_RFC2822:
                return gmdate( "D, j M Y H:i:s", $uts ) . ' GMT';
        default:
-               return;
+               wfDebugDieBacktrace( 'wfTimestamp() called with illegal output type.');
        }
 }