39 protected static $log = [];
76 public static function init() {
77 self::$enabled =
true;
86 self::$enabled =
false;
97 if ( self::$enabled ) {
98 $out->addModules(
'mediawiki.debug' );
108 public static function log( $str ) {
109 if ( !self::$enabled ) {
137 self::$deprecationWarnings = [];
151 public static function warning( $msg, $callerOffset = 1, $level = E_USER_NOTICE, $log =
'auto' ) {
158 if (
$log ===
'debug' ) {
162 $callerDescription = self::getCallerDescription( $callerOffset );
164 self::sendMessage( $msg, $callerDescription,
'warning', $level );
166 if ( self::$enabled ) {
170 'caller' => $callerDescription[
'func'],
193 public static function deprecated( $function, $version =
false,
194 $component =
false, $callerOffset = 2
196 $callerDescription = self::getCallerDescription( $callerOffset );
197 $callerFunc = $callerDescription[
'func'];
202 if (
isset( self::$deprecationWarnings[$function][$callerFunc] ) ) {
204 }
elseif (
isset( self::$deprecationWarnings[$function] ) ) {
205 if ( self::$enabled ) {
217 # Strip -* off the end of $version so that branches can use the
218 # format #.##-branchname to avoid issues if the branch is merged into
219 # a version of MediaWiki later than what it was branched from
220 $comparableVersion =
preg_replace(
'/-.*$/',
'', $version );
222 # If the comparableVersion is larger than our release limit then
223 # skip the warning message for the deprecation
229 $component = $component ===
false ?
'MediaWiki' :
$component;
230 $msg =
"Use of $function was deprecated in $component $version.";
232 $msg =
"Use of $function is deprecated.";
245 if ( self::$enabled ) {
247 Html::rawElement(
'div', [
'class' =>
'mw-debug-backtrace' ],
248 Html::element(
'span', [],
'Backtrace:' ) .
wfBacktrace()
253 'type' =>
'deprecated',
269 if (
isset( $callers[$callerOffset] ) ) {
271 if (
isset( $callerfile[
'file'] ) &&
isset( $callerfile[
'line'] ) ) {
272 $file = $callerfile[
'file'] .
' at line ' . $callerfile[
'line'];
274 $file =
'(internal function)';
277 $file =
'(unknown location)';
280 if (
isset( $callers[$callerOffset + 1] ) ) {
281 $callerfunc = $callers[$callerOffset + 1];
283 if (
isset( $callerfunc[
'class'] ) ) {
284 $func .= $callerfunc[
'class'] .
'::';
286 if (
isset( $callerfunc[
'function'] ) ) {
287 $func .= $callerfunc[
'function'];
305 private static function sendMessage( $msg, $caller, $group, $level ) {
306 $msg .=
' [Called from ' . $caller[
'func'] .
' in ' . $caller[
'file'] .
']';
308 if ( $level !==
false ) {
332 $prefix =
"[{$context['channel']}] ";
335 $prefix .=
"{$context['seconds_elapsed']} {$context['memory_used']} ";
337 $str = LegacyLogger::interpolate( $str,
$context );
338 $str = $prefix . $str;
340 self::$debug[] =
rtrim( UtfNormal\Validator::cleanUp( $str ) );
354 public static function query( $sql, $function, $isMaster, $runTime ) {
355 if ( !self::$enabled ) {
363 [\xC0-\xC1] # Invalid UTF-8 Bytes
364 | [\xF5-\xFF] # Invalid UTF-8 Bytes
365 | \xE0[\x80-\x9F] # Overlong encoding of prior code point
366 | \xF0[\x80-\x8F] # Overlong encoding of prior code point
367 | [\xC2-\xDF](?![\x80-\xBF]) # Invalid UTF-8 Sequence Start
368 | [\xE0-\xEF](?![\x80-\xBF]{2}) # Invalid UTF-8 Sequence Start
369 | [\xF0-\xF4](?![\x80-\xBF]{3}) # Invalid UTF-8 Sequence Start
370 | (?<=[\x0-\x7F\xF5-\xFF])[\x80-\xBF] # Invalid UTF-8 Sequence Middle
371 | (?<![\xC2-\xDF]|[\xE0-\xEF]|[\xE0-\xEF][\x80-\xBF]|[\xF0-\xF4]
372 | [\xF0-\xF4][\x80-\xBF]|[\xF0-\xF4][\x80-\xBF]{2})[\x80-\xBF] # Overlong Sequence
373 | (?<=[\xE0-\xEF])[\x80-\xBF](?![\x80-\xBF]) # Short 3 byte sequence
374 | (?<=[\xF0-\xF4])[\x80-\xBF](?![\x80-\xBF]{2}) # Short 4 byte sequence
375 | (?<=[\xF0-\xF4][\x80-\xBF])[\x80-\xBF](?![\x80-\xBF]) # Short 4 byte sequence (2)
382 $sql = UtfNormal\Validator::cleanUp( $sql );
387 'master' => (
bool)$isMaster,
403 foreach ( $files as $file ) {
407 'size' =>
$context->getLanguage()->formatSize( $size ),
426 if ( self::$enabled ) {
427 self::log(
'MWDebug output complete' );
428 $debugInfo = self::getDebugInfo(
$context );
432 $html = ResourceLoader::makeInlineScript(
433 ResourceLoader::makeConfigSetScript( [
'debugInfo' => $debugInfo ] ),
434 $context->getOutput()->getCSPNonce()
439 $html .=
"<!-- Debug output:\n" .
462 $ret =
"\n<hr />\n<strong>Debug data:</strong><ul id=\"mw-debug-html\">\n";
464 foreach ( self::$debug as
$line ) {
467 $ret .=
"<li><code>$display</code></li>\n";
470 $ret .=
'</ul>' .
"\n";
482 if ( !self::$enabled ) {
490 $obContentArray = explode(
'<br />', $obContents );
491 foreach ( $obContentArray as $obContent ) {
492 if (
trim( $obContent ) ) {
493 self::debugMsg( Sanitizer::stripAllTags( $obContent ) );
498 self::log(
'MWDebug output complete' );
499 $debugInfo = self::getDebugInfo(
$context );
506 $result->addValue(
null,
'debuginfo', $debugInfo );
516 if ( !self::$enabled ) {
538 'phpEngine' =>
wfIsHHVM() ?
'HHVM' :
'PHP',
543 'time' =>
$request->getElapsedTime(),
550 'headers' =>
$request->getAllHeaders(),
555 'includes' => self::getFilesIncluded(
$context ),
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
$wgDeprecationReleaseLimit
Release limitation to wfDeprecated warnings, if set to a release number development warnings will not...
$wgDebugComments
Send debug data to an HTML comment in the output.
$wgVersion
MediaWiki version number.
$wgShowDebug
Display debug data at the bottom of the main content area.
$wgDevelopmentWarnings
If set to true MediaWiki will throw notices for some possible error conditions and for deprecated fun...
wfBacktrace( $raw=null)
Get a debug backtrace as a string.
wfGetCaller( $level=2)
Get the name of the function which called this function wfGetCaller( 1 ) is the function with the wfG...
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
wfDebugBacktrace( $limit=0)
Safety wrapper for debug_backtrace().
wfIsHHVM()
Check if we are running under HHVM.
This class represents the result of the API operations.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
static isSHA1( $str)
Check if a string looks like a hex encoded SHA1 hash.
New debugger system that outputs a toolbar on page view.
static warning( $msg, $callerOffset=1, $level=E_USER_NOTICE, $log='auto')
Adds a warning entry to the log.
static getFilesIncluded(IContextSource $context)
Returns a list of files included, along with their size.
static $enabled
Is the debugger enabled?
static addModules(OutputPage $out)
Add ResourceLoader modules to the OutputPage object if debugging is enabled.
static appendDebugInfoToApiResult(IContextSource $context, ApiResult $result)
Append the debug info to given ApiResult.
static $deprecationWarnings
Array of functions that have already been warned, formatted function-caller to prevent a buttload of ...
static clearLog()
Clears internal log array and deprecation tracking.
static deinit()
Disable the debugger.
static query( $sql, $function, $isMaster, $runTime)
Begins profiling on a database query.
static getLog()
Returns internal log array.
static log( $str)
Adds a line to the log.
static getDebugInfo(IContextSource $context)
Returns the HTML to add to the page for the toolbar.
static debugMsg( $str, $context=[])
This is a method to pass messages from wfDebug to the pretty debugger.
static getCallerDescription( $callerOffset)
Get an array describing the calling function at a specified offset.
static deprecated( $function, $version=false, $component=false, $callerOffset=2)
Show a warning that $function is deprecated.
static sendMessage( $msg, $caller, $group, $level)
Send a message to the debug log and optionally also trigger a PHP error, depending on the $level argu...
static getHTMLDebugLog()
Generate debug log in HTML for displaying at the bottom of the main content area.
static init()
Enabled the debugger and load resource module.
static getDebugHTML(IContextSource $context)
Returns the HTML to add to the page for the toolbar.
This class should be covered by a general architecture document which does not exist as of January 20...
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
processing should stop and the error should be shown to the user * false
Interface for objects which can provide a MediaWiki context on request.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file