From 0f33c14576dec0f15fff78e9c5f0dcb959c5ef07 Mon Sep 17 00:00:00 2001 From: Erik Bernhardson Date: Thu, 17 Oct 2013 15:41:38 -0700 Subject: [PATCH] Remove 'Debug' hook from wfDebug and wfDebugLog 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 | 2 ++ docs/hooks.txt | 4 ---- includes/GlobalFunctions.php | 18 +++++++----------- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22 index 289f008723..2171dba409 100644 --- a/RELEASE-NOTES-1.22 +++ b/RELEASE-NOTES-1.22 @@ -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 diff --git a/docs/hooks.txt b/docs/hooks.txt index 53993de162..26032cb5b2 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -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 diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 8241d81ae9..f2a8dab2e3 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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 ); } -- 2.20.1