Go to the documentation of this file.
76 public static function init() {
77 self::$enabled =
true;
88 if ( self::$enabled ) {
89 $out->addModules(
'mediawiki.debug.init' );
101 public static function log( $str ) {
102 if ( !self::$enabled ) {
106 self::$log[] =
array(
107 'msg' => htmlspecialchars( $str ),
127 self::$log =
array();
128 self::$deprecationWarnings =
array();
144 public static function warning( $msg, $callerOffset = 1, $level = E_USER_NOTICE,
$log =
'auto' ) {
145 global $wgDevelopmentWarnings;
147 if (
$log ===
'auto' && !$wgDevelopmentWarnings ) {
151 if (
$log ===
'debug' ) {
159 if ( self::$enabled ) {
160 self::$log[] =
array(
161 'msg' => htmlspecialchars( $msg ),
163 'caller' => $callerDescription[
'func'],
188 $component =
false, $callerOffset = 2
191 $callerFunc = $callerDescription[
'func'];
196 if ( isset( self::$deprecationWarnings[$function][$callerFunc] ) ) {
198 } elseif ( isset( self::$deprecationWarnings[$function] ) ) {
199 if ( self::$enabled ) {
206 self::$deprecationWarnings[$function][$callerFunc] =
true;
209 global $wgDeprecationReleaseLimit;
210 if ( $wgDeprecationReleaseLimit && $component ===
false ) {
211 # Strip -* off the end of $version so that branches can use the
212 # format #.##-branchname to avoid issues if the branch is merged into
213 # a version of MediaWiki later than what it was branched from
214 $comparableVersion = preg_replace(
'/-.*$/',
'',
$version );
216 # If the comparableVersion is larger than our release limit then
217 # skip the warning message for the deprecation
218 if ( version_compare( $wgDeprecationReleaseLimit, $comparableVersion,
'<' ) ) {
223 $component = $component ===
false ?
'MediaWiki' : $component;
224 $msg =
"Use of $function was deprecated in $component $version.";
226 $msg =
"Use of $function is deprecated.";
230 global $wgDevelopmentWarnings;
235 $wgDevelopmentWarnings ? E_USER_DEPRECATED :
false
239 if ( self::$enabled ) {
240 $logMsg = htmlspecialchars( $msg ) .
245 self::$log[] =
array(
247 'type' =>
'deprecated',
248 'caller' => $callerFunc,
263 if ( isset( $callers[$callerOffset] ) ) {
264 $callerfile = $callers[$callerOffset];
265 if ( isset( $callerfile[
'file'] ) && isset( $callerfile[
'line'] ) ) {
266 $file = $callerfile[
'file'] .
' at line ' . $callerfile[
'line'];
268 $file =
'(internal function)';
271 $file =
'(unknown location)';
274 if ( isset( $callers[$callerOffset + 1] ) ) {
275 $callerfunc = $callers[$callerOffset + 1];
277 if ( isset( $callerfunc[
'class'] ) ) {
278 $func .= $callerfunc[
'class'] .
'::';
280 if ( isset( $callerfunc[
'function'] ) ) {
281 $func .= $callerfunc[
'function'];
287 return array(
'file' =>
$file,
'func' => $func );
299 private static function sendMessage( $msg, $caller, $group, $level ) {
300 $msg .=
' [Called from ' . $caller[
'func'] .
' in ' . $caller[
'file'] .
']';
302 if ( $level !==
false ) {
303 trigger_error( $msg, $level );
317 global $wgDebugComments, $wgShowDebug;
319 if ( self::$enabled || $wgDebugComments || $wgShowDebug ) {
334 public static function query( $sql, $function, $isMaster ) {
335 if ( !self::$enabled ) {
341 'function' => $function,
342 'master' => (
bool)$isMaster,
344 '_start' => microtime(
true ),
357 if ( $id === -1 || !self::$enabled ) {
372 $files = get_included_files();
397 if ( self::$enabled ) {
410 if ( $wgDebugComments ) {
411 $html .=
"<!-- Debug output:\n" .
428 global $wgDebugTimestamps, $wgShowDebug;
430 if ( !$wgShowDebug ) {
435 $ret =
"\n<hr />\n<strong>Debug data:</strong><ul id=\"mw-debug-html\">\n<li>";
439 if ( $wgDebugTimestamps ) {
441 if ( preg_match(
'/^(\d+\.\d+ {1,3}\d+.\dM\s{2})/',
$line,
$matches ) ) {
446 $display = ltrim(
$line );
447 $ident = strlen(
$line ) - strlen( $display );
448 $diff = $ident - $curIdent;
450 $display =
$pre . $display;
451 if ( $display ==
'' ) {
452 $display =
"\xc2\xa0";
457 && substr( $display, 0, 9 ) !=
'Entering '
458 && substr( $display, 0, 8 ) !=
'Exiting '
462 $display =
'<span style="background:yellow;">' .
463 nl2br( htmlspecialchars( $display ) ) .
'</span>';
465 $display = nl2br( htmlspecialchars( $display ) );
469 $ret .= str_repeat(
"</li></ul>\n", -$diff ) .
"</li><li>\n";
470 } elseif ( $diff == 0 ) {
471 $ret .=
"</li><li>\n";
473 $ret .= str_repeat(
"<ul><li>\n", $diff );
475 $ret .=
"<code>$display</code>\n";
480 $ret .= str_repeat(
'</li></ul>', $curIdent ) .
"</li>\n</ul>\n";
492 if ( !self::$enabled ) {
498 $obContents = ob_get_contents();
500 $obContentArray = explode(
'<br />', $obContents );
501 foreach ( $obContentArray
as $obContent ) {
502 if ( trim( $obContent ) ) {
511 $result->setIndexedTagName( $debugInfo,
'debuginfo' );
512 $result->setIndexedTagName( $debugInfo[
'log'],
'line' );
513 $result->setIndexedTagName( $debugInfo[
'debugLog'],
'msg' );
514 $result->setIndexedTagName( $debugInfo[
'queries'],
'query' );
515 $result->setIndexedTagName( $debugInfo[
'includes'],
'queries' );
516 $result->addValue(
null,
'debuginfo', $debugInfo );
526 if ( !self::$enabled ) {
540 'mwVersion' => $wgVersion,
541 'phpVersion' => PHP_VERSION,
550 'method' => $request->getMethod(),
551 'url' => $request->getRequestURL(),
552 'headers' => $request->getAllHeaders(),
553 'params' => $request->getValues(),
555 'memory' => $context->
getLanguage()->formatSize( memory_get_usage( $realMemoryUsage ) ),
556 'memoryPeak' => $context->
getLanguage()->formatSize( memory_get_peak_usage( $realMemoryUsage ) ),
static makeLoaderConditionalScript( $script)
Returns JS code which runs given JS code if the client-side framework is present.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. $title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetMagic':DEPRECATED, use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetSpecialPageAliases':DEPRECATED, use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
static getDebugHTML(IContextSource $context)
Returns the HTML to add to the page for the toolbar.
static query( $sql, $function, $isMaster)
Begins profiling on a database query.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
static makeConfigSetScript(array $configuration)
Returns JS code which will set the MediaWiki configuration array to the given value.
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
New debugger system that outputs a toolbar on page view.
static instance()
Singleton.
wfDebugBacktrace( $limit=0)
Safety wrapper for debug_backtrace().
static cleanUp( $string)
The ultimate convenience function! Clean up invalid UTF-8 sequences, and convert to normal form C,...
wfDebugLog( $logGroup, $text, $dest='all')
Send a line to a supplementary debug log file, if configured, or main debug log if not.
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
static debugMsg( $str)
This is a method to pass messages from wfDebug to the pretty debugger.
static getHTMLDebugLog()
Generate debug log in HTML for displaying at the bottom of the main content area.
static $debug
Debug messages from wfDebug().
static getCallerDescription( $callerOffset)
Get an array describing the calling function at a specified offset.
static getLog()
Returns internal log array.
static inlineScript( $contents)
Output a "<script>" tag with the given contents.
static stripAllTags( $text)
Take a fragment of (potentially invalid) HTML and return a version with any tags removed,...
wfBacktrace()
Get a debug backtrace as a string.
static getFilesIncluded(IContextSource $context)
Returns a list of files included, along with their size.
This class represents the result of the API operations.
static element( $element, $attribs=array(), $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
return true to allow those checks to and false if checking is done use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped $pre
static queryTime( $id)
Calculates how long a query took.
static $deprecationWarnings
Array of functions that have already been warned, formatted function-caller to prevent a buttload of ...
static getDebugInfo(IContextSource $context)
Returns the HTML to add to the page for the toolbar.
static clearLog()
Clears internal log array and deprecation tracking.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
static deprecated( $function, $version=false, $component=false, $callerOffset=2)
Show a warning that $function is deprecated.
when a variable name is used in a it is silently declared as a new masking the global
This class should be covered by a general architecture document which does not exist as of January 20...
static log( $str)
Adds a line to the log.
static appendDebugInfoToApiResult(IContextSource $context, ApiResult $result)
Append the debug info to given ApiResult.
if(!defined( 'MEDIAWIKI')) if(!isset( $wgVersion)) $matches
static init()
Enabled the debugger and load resource module.
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...
Interface for objects which can provide a context on request.
if(PHP_SAPI !='cli') $file
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
static addModules(OutputPage $out)
Add ResourceLoader modules to the OutputPage object if debugging is enabled.
getRequest()
Get the WebRequest object.
static warning( $msg, $callerOffset=1, $level=E_USER_NOTICE, $log='auto')
Adds a warning entry to the log.
static rawElement( $element, $attribs=array(), $contents='')
Returns an HTML element in a string.
return true to allow those checks to and false if checking is done use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped add a value to it if you want to add a cookie that have to vary cache options can modify $query
wfIsHHVM()
Check if we are running under HHVM.
static $query
SQL statements of the databses queries.
wfGetCaller( $level=2)
Get the name of the function which called this function wfGetCaller( 1 ) is the function with the wfG...
getLanguage()
Get the Language object.
static $enabled
Is the debugger enabled?