24use Wikimedia\ScopedCallback;
51 if ( isset(
$params[
'profileID'] ) ) {
52 $this->profileID =
$params[
'profileID'];
63 if ( self::$instance ===
null ) {
67 'class' => ProfilerStub::class,
76 $inSample = mt_rand( 0,
$params[
'sampling'] - 1 ) === 0;
78 if ( PHP_SAPI ===
'cli' || PHP_SAPI ===
'phpdbg' || !$inSample ) {
79 $params[
'class'] = ProfilerStub::class;
82 if ( !is_array(
$params[
'output'] ) ) {
88 return self::$instance;
99 if ( self::$instance && !( self::$instance instanceof
ProfilerStub ) ) {
100 throw new MWException(
'Could not replace non-stub profiler instance.' );
102 self::$instance = $profiler;
110 $this->profileID = $id;
117 if ( $this->profileID ===
false ) {
120 return $this->profileID;
141 if ( $this->context ) {
144 wfDebug( __METHOD__ .
" called and \$context is null. " .
145 "Return RequestContext::getMain(); for sanity\n" );
179 return $this->trxProfiler;
196 foreach ( $this->params[
'output'] as $outputType ) {
200 $outputClass = strpos( $outputType,
'ProfilerOutput' ) ===
false
201 ?
'ProfilerOutput' . ucfirst( $outputType )
203 if ( !class_exists( $outputClass ) ) {
204 throw new MWException(
"'$outputType' is an invalid output type" );
206 $outputInstance =
new $outputClass( $this, $this->params );
207 if ( $outputInstance->canUse() ) {
208 $outputs[] = $outputInstance;
222 $timeElapsed =
$request->getElapsedTime();
223 $timeElapsedThreshold = $this->params[
'threshold'];
224 if ( $timeElapsed <= $timeElapsedThreshold ) {
234 foreach ( $outputs as
$output ) {
261 foreach ( headers_list() as
$header ) {
262 if ( preg_match(
'#^content-type: (\w+/\w+);?#i',
$header, $m ) ) {
275 $this->templated =
$t;
284 return $this->templated;
$wgProfileLimit
Only record profiling info for pages that took longer than this.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
if(!defined( 'MEDIAWIKI')) $wgProfiler
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
The least sophisticated profiler output class possible, view your source! :)
Stub profiler that does nothing.
Profiler base class that defines the interface and some trivial functionality.
static replaceStubInstance(Profiler $profiler)
Replace the current profiler with $profiler if no non-stub profiler is set.
bool $templated
Whether MediaWiki is in a SkinTemplate output context.
string bool $profileID
Profiler ID for bucketing data.
static Profiler $instance
setContext( $context)
Sets the context for this Profiler.
setTemplated( $t)
Mark this call as templated or not.
getOutputs()
Get all usable outputs.
close()
Close opened profiling sections.
logData()
Log the data to some store or even the page output.
TransactionProfiler $trxProfiler
__construct(array $params)
profileOut( $functionname)
logDataPageOutputOnly()
Output current data to the page output if configured to do so.
getOutput()
Returns a profiling output to be stored in debug file.
static instance()
Singleton.
getContentType()
Get the content type sent out to the client.
getFunctionStats()
Get the aggregated inclusive profiling data for each method.
scopedProfileIn( $section)
Mark the start of a custom profiling frame (e.g.
getTemplated()
Was this call as templated or not.
scopedProfileOut(SectionProfileCallback &$section=null)
profileIn( $functionname)
getContext()
Gets the context for this Profiler.
static getMain()
Get the RequestContext object associated with the main request.
Subclass ScopedCallback to avoid call_user_func_array(), which is slow.
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
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place $output
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
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
Interface for objects which can provide a MediaWiki context on request.