MediaWiki
master
|
New debugger system that outputs a toolbar on page view. More...
Static Public Member Functions | |
static | addModules (OutputPage $out) |
Add ResourceLoader modules to the OutputPage object if debugging is enabled. More... | |
static | appendDebugInfoToApiResult (IContextSource $context, ApiResult $result) |
Append the debug info to given ApiResult. More... | |
static | clearDeprecationFilters () |
Clear all deprecation filters. More... | |
static | clearLog () |
Clears internal log array and deprecation tracking. More... | |
static | debugMsg ( $str, $context=[]) |
This is a method to pass messages from wfDebug to the pretty debugger. More... | |
static | deinit () |
Disable the debugger. More... | |
static | deprecated ( $function, $version=false, $component=false, $callerOffset=2) |
Show a warning that $function is deprecated. More... | |
static | deprecatedMsg ( $msg, $version=false, $component=false, $callerOffset=2) |
Log a deprecation warning with arbitrary message text. More... | |
static | detectDeprecatedOverride ( $instance, $class, $method, $version=false, $component=false, $callerOffset=2) |
Show a warning if $method declared in $class is overridden in $instance. More... | |
static | filterDeprecationForTest (string $regex, ?callable $callback=null) |
Deprecation messages matching the supplied regex will be suppressed. More... | |
static | getDebugHTML (IContextSource $context) |
Returns the HTML to add to the page for the toolbar. More... | |
static | getDebugInfo (IContextSource $context) |
Returns the HTML to add to the page for the toolbar. More... | |
static | getHTMLDebugLog () |
Generate debug log in HTML for displaying at the bottom of the main content area. More... | |
static | getLog () |
Returns internal log array. More... | |
static | init () |
Enabled the debugger and load resource module. More... | |
static | log ( $str) |
Adds a line to the log. More... | |
static | parseCallerDescription ( $msg) |
Append a caller description to an error message. More... | |
static | query ( $sql, $function, $runTime, $dbhost) |
Begins profiling on a database query. More... | |
static | sendRawDeprecated ( $msg, $sendToLog=true, $callerFunc='') |
Send a raw deprecation message to the log and the debug toolbar, without filtering of duplicate messages. More... | |
static | setup () |
static | warning ( $msg, $callerOffset=1, $level=E_USER_NOTICE, $log='auto') |
Adds a warning entry to the log. More... | |
Static Protected Member Functions | |
static | getFilesIncluded (IContextSource $context) |
Returns a list of files included, along with their size. More... | |
Static Protected Attributes | |
static array | $debug = [] |
Debug messages from wfDebug(). More... | |
static array | $deprecationFilters = [] |
Keys are regexes, values are optional callbacks to call if the filter is hit. More... | |
static array | $deprecationWarnings = [] |
Array of functions that have already been warned, formatted function-caller to prevent a buttload of warnings. More... | |
static bool | $enabled = false |
Is the debugger enabled? More... | |
static array | $log = [] |
Log lines. More... | |
static array | $query = [] |
SQL statements of the database queries. More... | |
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.
Definition at line 37 of file MWDebug.php.
|
static |
Add ResourceLoader modules to the OutputPage object if debugging is enabled.
OutputPage | $out |
Definition at line 129 of file MWDebug.php.
References OutputPage\addModules().
Referenced by OutputPage\output().
|
static |
Append the debug info to given ApiResult.
IContextSource | $context | |
ApiResult | $result |
Definition at line 681 of file MWDebug.php.
References ApiResult\addValue(), ApiResult\setIndexedTagName(), and Sanitizer\stripAllTags().
Referenced by ApiMain\executeAction().
|
static |
Clear all deprecation filters.
Definition at line 418 of file MWDebug.php.
|
static |
Clears internal log array and deprecation tracking.
Definition at line 168 of file MWDebug.php.
|
static |
This is a method to pass messages from wfDebug to the pretty debugger.
Do NOT use this method, use MWDebug::log or wfDebug()
string | $str | |
array | $context |
Definition at line 522 of file MWDebug.php.
References $wgDebugComments, and $wgShowDebug.
Referenced by MediaWiki\Logger\LegacyLogger\log().
|
static |
Disable the debugger.
Definition at line 118 of file MWDebug.php.
Referenced by RebuildFileCache\finalSetup().
|
static |
Show a warning that $function is deprecated.
string | $function | Function that is deprecated. |
string | false | $version | Version in which the function was deprecated. |
string | bool | $component | Component to which the function belongs. If false, it is assumed the function is in MediaWiki core. |
int | $callerOffset | How far up the callstack is the original caller. 2 = function that called the function that called MWDebug::deprecated() (Added in 1.20). |
Definition at line 225 of file MWDebug.php.
References deprecatedMsg().
Referenced by wfDeprecated().
|
static |
Log a deprecation warning with arbitrary message text.
A caller description will be appended. If the message has already been sent for this caller, it won't be sent again.
Although there are component and version parameters, they are not automatically appended to the message. The message text should include information about when the thing was deprecated.
The warning will be sent to the following locations:
string | $msg | The message |
string | false | $version | Version of MediaWiki that the function was deprecated in. |
string | bool | $component | Component to which the function belongs. If false, it is assumed the function is in MediaWiki core. |
int | false | $callerOffset | How far up the call stack is the original caller. 2 = function that called the function that called us. If false, the caller description will not be appended. |
Definition at line 307 of file MWDebug.php.
References $wgDeprecationReleaseLimit, and sendRawDeprecated().
Referenced by deprecated(), detectDeprecatedOverride(), and wfDeprecatedMsg().
|
static |
Show a warning if $method declared in $class is overridden in $instance.
phpcs:ignore MediaWiki.Commenting.FunctionComment.ObjectTypeHintParam
object | $instance | Object on which to detect deprecated overrides (typically $this). |
string | $class | Class declaring the deprecated method (typically CLASS ) |
string | $method | The name of the deprecated method. |
string | false | $version | Version in which the method was deprecated. Does not issue deprecation warnings if false. |
string | bool | $component | Component to which the class belongs. If false, it is assumed the class is in MediaWiki core. |
int | $callerOffset | How far up the callstack is the original caller. 2 = function that called the function that called MWDebug::detectDeprecatedOverride() |
Definition at line 259 of file MWDebug.php.
References deprecatedMsg().
Referenced by Skin\getFooterIcons(), ContentHandler\getParserOutput(), AbstractContent\getParserOutput(), Skin\makeFooterIcon(), AbstractContent\prepareSave(), QueryPage\reallyDoQuery(), and ContentHandler\validateSave().
|
static |
Deprecation messages matching the supplied regex will be suppressed.
Use this to filter deprecation warnings when testing deprecated code.
string | $regex | |
?callable | $callback To call if $regex is hit |
Definition at line 406 of file MWDebug.php.
|
static |
Returns the HTML to add to the page for the toolbar.
IContextSource | $context |
Definition at line 619 of file MWDebug.php.
References $wgDebugComments, and IContextSource\getOutput().
Referenced by BaseTemplate\getTrail(), and OutputPage\tailElement().
|
static |
Returns the HTML to add to the page for the toolbar.
IContextSource | $context |
Definition at line 715 of file MWDebug.php.
References GitInfo\currentBranch(), IContextSource\getLanguage(), IContextSource\getRequest(), GitInfo\headSHA1(), GitInfo\headViewUrl(), GitInfo\isSHA1(), and MW_VERSION.
|
staticprotected |
Returns a list of files included, along with their size.
IContextSource | $context |
Definition at line 598 of file MWDebug.php.
References $file, and IContextSource\getLanguage().
|
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.
Definition at line 655 of file MWDebug.php.
References $wgShowDebug.
Referenced by SkinTemplate\prepareQuickTemplate(), and OutputPage\tailElement().
|
static |
Returns internal log array.
Definition at line 160 of file MWDebug.php.
References $log.
|
static |
Enabled the debugger and load resource module.
This is called by Setup.php when $wgDebugToolbar is true.
Definition at line 109 of file MWDebug.php.
Referenced by setup().
|
static |
Adds a line to the log.
mixed | $str |
Definition at line 141 of file MWDebug.php.
References wfGetCaller().
|
static |
Append a caller description to an error message.
string | $msg | Formatted message from formatCallerDescription() and getCallerDescription() |
Definition at line 483 of file MWDebug.php.
Referenced by MWExceptionHandler\handleError().
|
static |
Begins profiling on a database query.
string | $sql | |
string | $function | |
float | $runTime | Query run time |
string | $dbhost |
Definition at line 553 of file MWDebug.php.
Referenced by MediaWiki\Logger\LegacyLogger\log().
|
static |
Send a raw deprecation message to the log and the debug toolbar, without filtering of duplicate messages.
A caller description will not be appended.
string | $msg | The complete message including relevant caller information. |
bool | $sendToLog | If true, the message will be sent to the debug toolbar, the debug log, and raised as a warning to PHP. If false, the message will only be sent to the debug toolbar. |
string | $callerFunc | The caller, for display in the debug toolbar's caller column. |
Definition at line 371 of file MWDebug.php.
References wfBacktrace().
Referenced by deprecatedMsg(), MediaWiki\HookContainer\HookContainer\emitDeprecationWarnings(), and MWLBFactory\logDeprecation().
|
static |
Definition at line 82 of file MWDebug.php.
References $wgCommandLineMode, $wgDebugToolbar, $wgUseCdn, $wgUseFileCache, and init().
|
static |
Adds a warning entry to the log.
string | $msg | |
int | $callerOffset | |
int | $level | A PHP error level. See sendMessage() |
string | $log | 'production' will always trigger a php error, 'auto' will trigger an error if $wgDevelopmentWarnings is true, and 'debug' will only write to the debug log(s). |
Definition at line 184 of file MWDebug.php.
References $log, and $wgDevelopmentWarnings.
Referenced by WikiExporter\outputPageStreamBatch(), GuzzleHttp\Psr7\Request\HeaderCallback\warnIfHeadersSent(), wfLogWarning(), and wfWarn().
|
staticprotected |
Debug messages from wfDebug().
Definition at line 50 of file MWDebug.php.
|
staticprotected |
Keys are regexes, values are optional callbacks to call if the filter is hit.
Definition at line 77 of file MWDebug.php.
|
staticprotected |
Array of functions that have already been warned, formatted function-caller to prevent a buttload of warnings.
Definition at line 72 of file MWDebug.php.
|
staticprotected |
Is the debugger enabled?
Definition at line 64 of file MWDebug.php.
|
staticprotected |
|
staticprotected |
SQL statements of the database queries.
Definition at line 57 of file MWDebug.php.