Remove 'Debug' hook from wfDebug and wfDebugLog
authorErik Bernhardson <ebernhardson@wikimedia.org>
Thu, 17 Oct 2013 22:41:38 +0000 (15:41 -0700)
committerErik Bernhardson <ebernhardson@wikimedia.org>
Thu, 17 Oct 2013 22:45:05 +0000 (15:45 -0700)
Per the bug report, the 'Debug' hook was triggering an infinite loop when
wgDebugFunctionEntry is enabled.  The Debug hook is used if an extension wants
to stop a debug message from being sent out.  Ideally the wfDebug and related
functions should be as low-level and avoid calling other code as much as
possible to avoid situations like this.

Bug: 55818
Change-Id: I679782489b683503fc624cfea3c7ad72a989b005

RELEASE-NOTES-1.22
docs/hooks.txt
includes/GlobalFunctions.php

index 289f008..2171dba 100644 (file)
@@ -329,6 +329,8 @@ production.
 * (bug 47191) Fixed "Column 'si_title' cannot be part of FULLTEXT index"
   MySQL error when installing using the binary character set option.
 * (bug 45288) Support mysqli PHP extension
+* (bug 55818) BREAKING CHANGE: Removed undocumented 'Debug' hook in wfDebug.
+  This resolves an infinite loop when using $wgDebugFunctionEntry = true.
 
 === API changes in 1.22 ===
 * (bug 25553) The JSON output formatter now leaves forward slashes unescaped
index 53993de..26032cb 100644 (file)
@@ -866,10 +866,6 @@ etc.
 'DatabaseOraclePostInit': Called after initialising an Oracle database
 &$db: the DatabaseOracle object
 
-'Debug': Called when outputting a debug log line via wfDebug() or wfDebugLog()
-$text: plaintext string to be output
-$group: null or a string naming a logging group (as defined in $wgDebugLogGroups)
-
 'NewDifferenceEngine': Called when a new DifferenceEngine object is made
 $title: the diff page title (nullable)
 &$oldId: the actual old Id to use in the diff
index 8241d81..f2a8dab 100644 (file)
@@ -931,14 +931,12 @@ function wfDebug( $text, $logonly = false ) {
                MWDebug::debugMsg( $text );
        }
 
-       if ( wfRunHooks( 'Debug', array( $text, null /* no log group */ ) ) ) {
-               if ( $wgDebugLogFile != '' && !$wgProfileOnly ) {
-                       # Strip unprintables; they can switch terminal modes when binary data
-                       # gets dumped, which is pretty annoying.
-                       $text = preg_replace( '![\x00-\x08\x0b\x0c\x0e-\x1f]!', ' ', $text );
-                       $text = $wgDebugLogPrefix . $text;
-                       wfErrorLog( $text, $wgDebugLogFile );
-               }
+       if ( $wgDebugLogFile != '' && !$wgProfileOnly ) {
+               # Strip unprintables; they can switch terminal modes when binary data
+               # gets dumped, which is pretty annoying.
+               $text = preg_replace( '![\x00-\x08\x0b\x0c\x0e-\x1f]!', ' ', $text );
+               $text = $wgDebugLogPrefix . $text;
+               wfErrorLog( $text, $wgDebugLogFile );
        }
 }
 
@@ -1013,9 +1011,7 @@ function wfDebugLog( $logGroup, $text, $public = true ) {
                $time = wfTimestamp( TS_DB );
                $wiki = wfWikiID();
                $host = wfHostname();
-               if ( wfRunHooks( 'Debug', array( $text, $logGroup ) ) ) {
-                       wfErrorLog( "$time $host $wiki: $text", $wgDebugLogGroups[$logGroup] );
-               }
+               wfErrorLog( "$time $host $wiki: $text", $wgDebugLogGroups[$logGroup] );
        } elseif ( $public === true ) {
                wfDebug( "[$logGroup] $text", false );
        }