From 1833e43b5a03c75b3d18752b50fe6fbd83eea45e Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sat, 24 Sep 2005 13:37:26 +0000 Subject: [PATCH] Move reporttime method from OutputPage object to a global function, let us use it for diewithtraceback --- includes/GlobalFunctions.php | 38 +++++++++++++++++++++++++++++++++--- includes/OutputPage.php | 27 ++++--------------------- 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 27d59eb535..b8c6c76dd2 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -504,11 +504,43 @@ function wfDebugDieBacktrace( $msg = '' ) { } else { $msg .= "\n

Backtrace:

\n$backtrace"; } - } - echo $msg; - die( -1 ); + } + echo $msg; + echo wfReportTime(); + die( -1 ); } + /** + * Returns a HTML comment with the elapsed time since request. + * This method has no side effects. + * @return string + */ + function wfReportTime() { + global $wgRequestTime; + + $now = wfTime(); + list( $usec, $sec ) = explode( ' ', $wgRequestTime ); + $start = (float)$sec + (float)$usec; + $elapsed = $now - $start; + + # Use real server name if available, so we know which machine + # in a server farm generated the current page. + if ( function_exists( 'posix_uname' ) ) { + $uname = @posix_uname(); + } else { + $uname = false; + } + if( is_array( $uname ) && isset( $uname['nodename'] ) ) { + $hostname = $uname['nodename']; + } else { + # This may be a virtual server. + $hostname = $_SERVER['SERVER_NAME']; + } + $com = sprintf( "", + $hostname, $elapsed ); + return $com; + } + function wfBacktrace() { global $wgCommandLineMode; if ( !function_exists( 'debug_backtrace' ) ) { diff --git a/includes/OutputPage.php b/includes/OutputPage.php index aa46207a96..2c960bd8b7 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -505,32 +505,13 @@ class OutputPage { /** * Returns a HTML comment with the elapsed time since request. * This method has no side effects. + * Use wfReportTime() instead. * @return string + * @deprecated */ function reportTime() { - global $wgRequestTime; - - $now = wfTime(); - list( $usec, $sec ) = explode( ' ', $wgRequestTime ); - $start = (float)$sec + (float)$usec; - $elapsed = $now - $start; - - # Use real server name if available, so we know which machine - # in a server farm generated the current page. - if ( function_exists( 'posix_uname' ) ) { - $uname = @posix_uname(); - } else { - $uname = false; - } - if( is_array( $uname ) && isset( $uname['nodename'] ) ) { - $hostname = $uname['nodename']; - } else { - # This may be a virtual server. - $hostname = $_SERVER['SERVER_NAME']; - } - $com = sprintf( "", - $hostname, $elapsed ); - return $com; + $time = wfReportTime(); + return $time; } /** -- 2.20.1