r11117 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r11116‎ | r11117 | r11118 >
Date:13:37, 24 September 2005
Author:hashar
Status:old
Tags:
Comment:
Move reporttime method from OutputPage object to a global function, let us use it for diewithtraceback
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -504,11 +504,43 @@
505505 } else {
506506 $msg .= "\n<p>Backtrace:</p>\n$backtrace";
507507 }
508 - }
509 - echo $msg;
510 - die( -1 );
 508+ }
 509+ echo $msg;
 510+ echo wfReportTime();
 511+ die( -1 );
511512 }
512513
 514+ /**
 515+ * Returns a HTML comment with the elapsed time since request.
 516+ * This method has no side effects.
 517+ * @return string
 518+ */
 519+ function wfReportTime() {
 520+ global $wgRequestTime;
 521+
 522+ $now = wfTime();
 523+ list( $usec, $sec ) = explode( ' ', $wgRequestTime );
 524+ $start = (float)$sec + (float)$usec;
 525+ $elapsed = $now - $start;
 526+
 527+ # Use real server name if available, so we know which machine
 528+ # in a server farm generated the current page.
 529+ if ( function_exists( 'posix_uname' ) ) {
 530+ $uname = @posix_uname();
 531+ } else {
 532+ $uname = false;
 533+ }
 534+ if( is_array( $uname ) && isset( $uname['nodename'] ) ) {
 535+ $hostname = $uname['nodename'];
 536+ } else {
 537+ # This may be a virtual server.
 538+ $hostname = $_SERVER['SERVER_NAME'];
 539+ }
 540+ $com = sprintf( "<!-- Served by %s in %01.2f secs. -->",
 541+ $hostname, $elapsed );
 542+ return $com;
 543+ }
 544+
513545 function wfBacktrace() {
514546 global $wgCommandLineMode;
515547 if ( !function_exists( 'debug_backtrace' ) ) {
Index: trunk/phase3/includes/OutputPage.php
@@ -505,32 +505,13 @@
506506 /**
507507 * Returns a HTML comment with the elapsed time since request.
508508 * This method has no side effects.
 509+ * Use wfReportTime() instead.
509510 * @return string
 511+ * @deprecated
510512 */
511513 function reportTime() {
512 - global $wgRequestTime;
513 -
514 - $now = wfTime();
515 - list( $usec, $sec ) = explode( ' ', $wgRequestTime );
516 - $start = (float)$sec + (float)$usec;
517 - $elapsed = $now - $start;
518 -
519 - # Use real server name if available, so we know which machine
520 - # in a server farm generated the current page.
521 - if ( function_exists( 'posix_uname' ) ) {
522 - $uname = @posix_uname();
523 - } else {
524 - $uname = false;
525 - }
526 - if( is_array( $uname ) && isset( $uname['nodename'] ) ) {
527 - $hostname = $uname['nodename'];
528 - } else {
529 - # This may be a virtual server.
530 - $hostname = $_SERVER['SERVER_NAME'];
531 - }
532 - $com = sprintf( "<!-- Served by %s in %01.2f secs. -->",
533 - $hostname, $elapsed );
534 - return $com;
 514+ $time = wfReportTime();
 515+ return $time;
535516 }
536517
537518 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r79752More ancient deprecated functions:...happy-melon20:40, 6 January 2011

Status & tagging log