r113647 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113646‎ | r113647 | r113648 >
Date:19:01, 12 March 2012
Author:ialex
Status:ok (Comments)
Tags:
Comment:
* Put the timer stuff after leading line breaks in debug log entries (mainly for the first call on a request) so that they are placed near the remaing text and not on its own line
* Normalise line breaks in the first entry on a web request so that it's consistent with the one for command line requests
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/Setup.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Setup.php
@@ -421,16 +421,16 @@
422422 # Can't stub this one, it sets up $_GET and $_REQUEST in its constructor
423423 $wgRequest = new WebRequest;
424424
425 - $debug = "Start request\n\n{$_SERVER['REQUEST_METHOD']} {$wgRequest->getRequestURL()}";
 425+ $debug = "\n\nStart request\n{$_SERVER['REQUEST_METHOD']} {$wgRequest->getRequestURL()}\n";
426426
427427 if ( $wgDebugPrintHttpHeaders ) {
428 - $debug .= "\nHTTP HEADERS:\n";
 428+ $debug .= "HTTP HEADERS:\n";
429429
430430 foreach ( $wgRequest->getAllHeaders() as $name => $value ) {
431431 $debug .= "$name: $value\n";
432432 }
433433 }
434 - wfDebug( "$debug\n" );
 434+ wfDebug( $debug );
435435 }
436436
437437 wfProfileOut( $fname . '-misc1' );
Index: trunk/phase3/includes/GlobalFunctions.php
@@ -876,12 +876,16 @@
877877 global $wgDebugLogPrefix, $wgShowDebug;
878878
879879 static $cache = array(); // Cache of unoutputted messages
880 - $text = wfDebugTimer() . $text;
881880
882881 if ( !$wgDebugRawPage && wfIsDebugRawPage() ) {
883882 return;
884883 }
885884
 885+ $timer = wfDebugTimer();
 886+ if ( $timer !== '' ) {
 887+ $text = preg_replace( '/[^\n]/', $timer . '\0', $text, 1 );
 888+ }
 889+
886890 if ( ( $wgDebugComments || $wgShowDebug ) && !$logonly ) {
887891 $cache[] = $text;
888892

Comments

#Comment by Aaron Schulz (talk | contribs)   20:26, 13 March 2012
+ $text = preg_replace( '/[^\n]/', $timer . '\0', $text, 1 );

Null byte?

#Comment by IAlex (talk | contribs)   20:39, 13 March 2012

No, it is what is captured by "[^\n]" in the regexp that would be lost otherwise

#Comment by Aaron Schulz (talk | contribs)   03:22, 14 March 2012

You can't use $0?

Status & tagging log