MediaWiki  REL1_20
MWDebug Class Reference

New debugger system that outputs a toolbar on page view. More...

List of all members.

Static Public Member Functions

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 clearLog ()
 Clears internal log array and deprecation tracking.
static debugMsg ($str)
 This is a method to pass messages from wfDebug to the pretty debugger.
static deprecated ($function, $version=false, $component=false, $callerOffset=2)
 Show a warning that $function is deprecated.
static getDebugHTML (IContextSource $context)
 Returns the HTML to add to the page for the toolbar.
static getDebugInfo (IContextSource $context)
 Returns the HTML to add to the page for the toolbar.
static getHTMLDebugLog ()
 Generate debug log in HTML for displaying at the bottom of the main content area.
static getLog ()
 Returns internal log array.
static init ()
 Enabled the debugger and load resource module.
static log ($str)
 Adds a line to the log.
static query ($sql, $function, $isMaster)
 Begins profiling on a database query.
static queryTime ($id)
 Calculates how long a query took.
static warning ($msg, $callerOffset=1, $level=E_USER_NOTICE)
 Adds a warning entry to the log.

Static Protected Member Functions

static getFilesIncluded (IContextSource $context)
 Returns a list of files included, along with their size.

Static Protected Attributes

static $debug = array()
static $deprecationWarnings = array()
static $enabled = false
static $log = array()
static $query = array()

Static Private Member Functions

static getCallerDescription ($callerOffset)
 Get an array describing the calling function at a specified offset.
static sendWarning ($msg, $caller, $level)
 Send a warning either to the debug log or by triggering an user PHP error depending on $wgDevelopmentWarnings.

Detailed Description

New debugger system that outputs a toolbar on page view.

By default, most methods do nothing ( self::$enabled = false ). You have to explicitly call MWDebug::init() to enabled them.

Todo:
Profiler support
Since:
1.19

Definition at line 33 of file Debug.php.


Member Function Documentation

static MWDebug::addModules ( OutputPage out) [static]

Add ResourceLoader modules to the OutputPage object if debugging is enabled.

Since:
1.19
Parameters:
$outOutputPage

Definition at line 88 of file Debug.php.

References OutputPage\addModules().

static MWDebug::appendDebugInfoToApiResult ( IContextSource context,
ApiResult result 
) [static]

Append the debug info to given ApiResult.

Parameters:
$contextIContextSource
$resultApiResult

Definition at line 465 of file Debug.php.

References ApiResult\addValue(), debugMsg(), getDebugInfo(), log(), ApiResult\setContent(), ApiResult\setIndexedTagName(), and Sanitizer\stripAllTags().

static MWDebug::clearLog ( ) [static]

Clears internal log array and deprecation tracking.

Since:
1.19

Definition at line 127 of file Debug.php.

Referenced by MWDebugTest\setUp().

static MWDebug::debugMsg ( str) [static]

This is a method to pass messages from wfDebug to the pretty debugger.

Do NOT use this method, use MWDebug::log or wfDebug()

Since:
1.19
Parameters:
$strstring

Definition at line 295 of file Debug.php.

Referenced by appendDebugInfoToApiResult(), and wfDebug().

static MWDebug::deprecated ( function,
version = false,
component = false,
callerOffset = 2 
) [static]

Show a warning that $function is deprecated.

This will send it to the following locations:

  • Debug toolbar, with one item per function and caller, if $wgDebugToolbar is set to true.
  • PHP's error log, with level E_USER_DEPRECATED, if $wgDevelopmentWarnings is set to true.
  • MediaWiki's debug log, if $wgDevelopmentWarnings is set to false.
Since:
1.19
Parameters:
$functionstring: Function that is deprecated.
$versionstring|bool: Version in which the function was deprecated.
$componentstring|bool: Component to which the function belongs. If false, it is assumbed the function is in MediaWiki core.
$callerOffsetinteger: How far up the callstack is the original caller. 2 = function that called the function that called MWDebug::deprecated() (Added in 1.20).
Returns:
mixed

Definition at line 173 of file Debug.php.

References Html\element(), getCallerDescription(), Html\rawElement(), sendWarning(), and wfBacktrace().

Referenced by MWDebugTest\testAvoidDuplicateDeprecations(), MWDebugTest\testAvoidNonConsecutivesDuplicateDeprecations(), and wfDeprecated().

static MWDebug::getCallerDescription ( callerOffset) [static, private]

Get an array describing the calling function at a specified offset.

Parameters:
$callerOffsetinteger: How far up the callstack is the original caller. 0 = function that called getCallerDescription()
Returns:
array with two keys: 'file' and 'func'

Definition at line 238 of file Debug.php.

References $file, and wfDebugBacktrace().

Referenced by deprecated(), and warning().

static MWDebug::getDebugHTML ( IContextSource context) [static]

Returns the HTML to add to the page for the toolbar.

Since:
1.19
Parameters:
$contextIContextSource
Returns:
string

Definition at line 371 of file Debug.php.

References getDebugInfo(), Html\inlineScript(), log(), ResourceLoader\makeConfigSetScript(), and ResourceLoader\makeLoaderConditionalScript().

Referenced by BaseTemplate\printTrail().

static MWDebug::getDebugInfo ( IContextSource context) [static]

Returns the HTML to add to the page for the toolbar.

Parameters:
$contextIContextSource
Returns:
array

Definition at line 504 of file Debug.php.

References $wgRequestTime, GitInfo\currentBranch(), getFilesIncluded(), IContextSource\getLanguage(), IContextSource\getRequest(), GitInfo\headSHA1(), and GitInfo\headViewUrl().

Referenced by appendDebugInfoToApiResult(), and getDebugHTML().

static MWDebug::getFilesIncluded ( IContextSource context) [static, protected]

Returns a list of files included, along with their size.

Parameters:
$contextIContextSource
Returns:
array

Definition at line 350 of file Debug.php.

References $file, $files, $size, and IContextSource\getLanguage().

Referenced by getDebugInfo().

static MWDebug::getHTMLDebugLog ( ) [static]

Generate debug log in HTML for displaying at the bottom of the main content area.

If $wgShowDebug is false, an empty string is always returned.

Since:
1.20
Returns:
string HTML fragment

Definition at line 406 of file Debug.php.

References $matches.

Referenced by Skin\generateDebugHTML().

static MWDebug::getLog ( ) [static]

Returns internal log array.

Since:
1.19
Returns:
array

Definition at line 119 of file Debug.php.

References $log.

Referenced by MWDebugTest\testAddLog(), MWDebugTest\testAddWarning(), MWDebugTest\testAvoidDuplicateDeprecations(), and MWDebugTest\testAvoidNonConsecutivesDuplicateDeprecations().

static MWDebug::init ( ) [static]

Enabled the debugger and load resource module.

This is called by Setup.php when $wgDebugToolbar is true.

Since:
1.19

Definition at line 77 of file Debug.php.

Referenced by MWDebugTest\setUp().

static MWDebug::log ( str) [static]

Adds a line to the log.

Todo:
Add support for passing objects
Since:
1.19
Parameters:
$strstring

Definition at line 102 of file Debug.php.

References wfGetCaller().

Referenced by appendDebugInfoToApiResult(), getDebugHTML(), MWDebugTest\testAddLog(), and MWDebugTest\testAvoidNonConsecutivesDuplicateDeprecations().

static MWDebug::query ( sql,
function,
isMaster 
) [static]

Begins profiling on a database query.

Since:
1.19
Parameters:
$sqlstring
$functionstring
$isMasterbool
Returns:
int ID number of the query to pass to queryTime or -1 if the debugger is disabled

Definition at line 313 of file Debug.php.

static MWDebug::queryTime ( id) [static]

Calculates how long a query took.

Since:
1.19
Parameters:
$idint

Definition at line 335 of file Debug.php.

static MWDebug::sendWarning ( msg,
caller,
level 
) [static, private]

Send a warning either to the debug log or by triggering an user PHP error depending on $wgDevelopmentWarnings.

Parameters:
$msgstring Message to send
$callerarray caller description get from getCallerDescription()
$levelerror level to use if $wgDevelopmentWarnings is true

Definition at line 276 of file Debug.php.

References wfDebug().

Referenced by deprecated(), and warning().

static MWDebug::warning ( msg,
callerOffset = 1,
level = E_USER_NOTICE 
) [static]

Adds a warning entry to the log.

Since:
1.19
Parameters:
$msgstring
$callerOffsetint
Returns:
mixed

Definition at line 140 of file Debug.php.

References getCallerDescription(), and sendWarning().

Referenced by MWDebugTest\testAddWarning(), MWDebugTest\testAvoidNonConsecutivesDuplicateDeprecations(), and wfWarn().


Member Data Documentation

MWDebug::$debug = array() [static, protected]

Definition at line 47 of file Debug.php.

MWDebug::$deprecationWarnings = array() [static, protected]

Definition at line 69 of file Debug.php.

MWDebug::$enabled = false [static, protected]

Definition at line 61 of file Debug.php.

MWDebug::$log = array() [static, protected]

Definition at line 40 of file Debug.php.

Referenced by getLog().

MWDebug::$query = array() [static, protected]

Definition at line 54 of file Debug.php.


The documentation for this class was generated from the following file: