From: Brion Vibber Date: Tue, 2 Jan 2007 23:50:56 +0000 (+0000) Subject: * (bug 8041) Work around bug with debug_backtrace when Zend Optimizer is X-Git-Tag: 1.31.0-rc.0~54689 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/ajouter.php?a=commitdiff_plain;h=1a6a78a0aa8fba750e48663f7897f4e9dacf6cfa;p=lhc%2Fweb%2Fwiklou.git * (bug 8041) Work around bug with debug_backtrace when Zend Optimizer is loaded by skipping the function. Use wfDebugBacktrace() wrapper function. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 3134ce8f02..97b5971c2b 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -453,6 +453,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN license is not actually set up * (bug 8463) Don't print external link icons for Monobook * (bug 8461) Support watching pages on move +* (bug 8041) Work around bug with debug_backtrace when Zend Optimizer is + loaded by skipping the function. Use wfDebugBacktrace() wrapper function. + == Languages updated == diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 175954512a..d91721bf84 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -581,8 +581,8 @@ function wfAbruptExit( $error = false ){ } $called = true; - if( function_exists( 'debug_backtrace' ) ){ // PHP >= 4.3 - $bt = debug_backtrace(); + $bt = wfDebugBacktrace(); + if( $bt ) { for($i = 0; $i < count($bt) ; $i++){ $file = isset($bt[$i]['file']) ? $bt[$i]['file'] : "unknown"; $line = isset($bt[$i]['line']) ? $bt[$i]['line'] : "unknown"; @@ -664,18 +664,36 @@ function wfHostname() { return $com; } +/** + * Safety wrapper for debug_backtrace(). + * + * With Zend Optimizer 3.2.0 loaded, this causes segfaults under somewhat + * murky circumstances, which may be triggered in part by stub objects + * or other fancy talkin'. + * + * Will return an empty array if Zend Optimizer is detected, otherwise + * the output from debug_backtrace() (trimmed). + * + * @return array of backtrace information + */ +function wfDebugBacktrace() { + if( extension_loaded( 'Zend Optimizer' ) ) { + wfDebug( "Zend Optimizer detected; skipping debug_backtrace for safety.\n" ); + return array(); + } else { + return array_slice( debug_backtrace(), 1 ); + } +} + function wfBacktrace() { global $wgCommandLineMode; - if ( !function_exists( 'debug_backtrace' ) ) { - return false; - } if ( $wgCommandLineMode ) { $msg = ''; } else { $msg = "