24use Wikimedia\ScopedCallback;
51 if ( isset(
$params[
'profileID'] ) ) {
52 $this->profileID =
$params[
'profileID'];
63 if ( self::$instance ===
null ) {
67 'class' =>
'ProfilerStub',
76 $inSample = mt_rand( 0,
$params[
'sampling'] - 1 ) === 0;
77 if ( PHP_SAPI ===
'cli' || !$inSample ) {
78 $params[
'class'] =
'ProfilerStub';
81 if ( !is_array(
$params[
'output'] ) ) {
87 return self::$instance;
98 if ( self::$instance && !( self::$instance instanceof
ProfilerStub ) ) {
99 throw new MWException(
'Could not replace non-stub profiler instance.' );
101 self::$instance = $profiler;
109 $this->profileID = $id;
116 if ( $this->profileID ===
false ) {
119 return $this->profileID;
140 if ( $this->context ) {
143 wfDebug( __METHOD__ .
" called and \$context is null. " .
144 "Return RequestContext::getMain(); for sanity\n" );
178 return $this->trxProfiler;
195 foreach ( $this->params[
'output'] as $outputType ) {
199 $outputClass = strpos( $outputType,
'ProfilerOutput' ) ===
false
200 ?
'ProfilerOutput' . ucfirst( $outputType )
202 if ( !class_exists( $outputClass ) ) {
203 throw new MWException(
"'$outputType' is an invalid output type" );
205 $outputInstance =
new $outputClass( $this, $this->params );
206 if ( $outputInstance->canUse() ) {
207 $outputs[] = $outputInstance;
221 $timeElapsed =
$request->getElapsedTime();
222 $timeElapsedThreshold = $this->params[
'threshold'];
223 if ( $timeElapsed <= $timeElapsedThreshold ) {
233 foreach ( $outputs as
$output ) {
260 foreach ( headers_list() as
$header ) {
261 if ( preg_match(
'#^content-type: (\w+/\w+);?#i',
$header, $m ) ) {
274 $this->templated =
$t;
283 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.
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()
Static methods.
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.