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 ) {
118 return WikiMap::getCurrentWikiDbDomain()->getId();
120 return $this->profileID;
141 if ( $this->context ) {
144 wfDebug( __METHOD__ .
" called and \$context is null. " .
145 "Return RequestContext::getMain(); for sanity\n" );
146 return RequestContext::getMain();
180 return $this->trxProfiler;
197 foreach ( $this->params[
'output']
as $outputType ) {
201 $outputClass = strpos( $outputType,
'ProfilerOutput' ) ===
false
202 ?
'ProfilerOutput' . ucfirst( $outputType )
204 if ( !class_exists( $outputClass ) ) {
205 throw new MWException(
"'$outputType' is an invalid output type" );
207 $outputInstance =
new $outputClass( $this, $this->params );
208 if ( $outputInstance->canUse() ) {
209 $outputs[] = $outputInstance;
223 $timeElapsed =
$request->getElapsedTime();
224 $timeElapsedThreshold = $this->params[
'threshold'];
225 if ( $timeElapsed <= $timeElapsedThreshold ) {
231 if ( !
$output->logsToOutput() ) {
253 if (
$output->logsToOutput() ) {
274 if ( preg_match(
'#^content-type: (\w+/\w+);?#i',
$header, $m ) ) {
287 $this->templated =
$t;
296 return $this->templated;
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$wgProfileLimit
Only record profiling info for pages that took longer than this.
$wgProfiler
Profiler configuration.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
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 the backing store for all ProfilerOutput instances that have one.
TransactionProfiler $trxProfiler
__construct(array $params)
profileOut( $functionname)
logDataPageOutputOnly()
Log the data to the script/request output for all ProfilerOutput instances that 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.
Subclass ScopedCallback to avoid call_user_func_array(), which is slow.
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
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
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
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place $output
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Interface for objects which can provide a MediaWiki context on request.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))