Make $wgDebugRawPage=false also ignore load.php, so that debug logs can be readable...
authorTim Starling <tstarling@users.mediawiki.org>
Tue, 31 May 2011 05:55:06 +0000 (05:55 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Tue, 31 May 2011 05:55:06 +0000 (05:55 +0000)
includes/DefaultSettings.php
includes/GlobalFunctions.php

index 628a56e..b25e37f 100644 (file)
@@ -3823,7 +3823,7 @@ $wgDebugLogPrefix       = '';
 $wgDebugRedirects              = false;
 
 /**
- * If true, log debugging data from action=raw.
+ * If true, log debugging data from action=raw and load.php.
  * This is normally false to avoid overlapping debug entries due to gen=css and
  * gen=js requests.
  */
index 17f9350..6ce6271 100644 (file)
@@ -331,8 +331,7 @@ function wfDebug( $text, $logonly = false ) {
        static $cache = array(); // Cache of unoutputted messages
        $text = wfDebugTimer() . $text;
 
-       # Check for raw action using $_GET not $wgRequest, since the latter might not be initialised yet
-       if ( isset( $_GET['action'] ) && $_GET['action'] == 'raw' && !$wgDebugRawPage ) {
+       if ( !$wgDebugRawPage && wfIsDebugRawPage() ) {
                return;
        }
 
@@ -356,6 +355,28 @@ function wfDebug( $text, $logonly = false ) {
        }
 }
 
+/**
+ * Returns true if debug logging should be suppressed if $wgDebugRawPage = false
+ */
+function wfIsDebugRawPage() {
+       static $cache;
+       if ( $cache !== null ) {
+               return $cache;
+       }
+       # Check for raw action using $_GET not $wgRequest, since the latter might not be initialised yet
+       if ( ( isset( $_GET['action'] ) && $_GET['action'] == 'raw' )
+               || ( 
+                       isset( $_SERVER['SCRIPT_NAME'] ) 
+                       && substr( $_SERVER['SCRIPT_NAME'], -8 ) == 'load.php' 
+               ) )     
+       {
+               $cache = true;
+       } else {
+               $cache = false;
+       }
+       return $cache;
+}
+
 /**
  * Get microsecond timestamps for debug logs
  * 
@@ -523,7 +544,7 @@ function wfLogProfilingData() {
        $profiler->logData();
 
        // Check whether this should be logged in the debug file.
-       if ( $wgDebugLogFile == '' || ( $wgRequest->getVal( 'action' ) == 'raw' && !$wgDebugRawPage ) ) {
+       if ( $wgDebugLogFile == '' || ( !$wgDebugRawPage && wfIsDebugRawPage() ) ) {
                return;
        }