24use Wikimedia\ScopedCallback;
50 if ( isset(
$params[
'profileID'] ) ) {
51 $this->profileID =
$params[
'profileID'];
62 if ( self::$instance ===
null ) {
66 'class' =>
'ProfilerStub',
75 $inSample = mt_rand( 0,
$params[
'sampling'] - 1 ) === 0;
76 if ( PHP_SAPI ===
'cli' || !$inSample ) {
77 $params[
'class'] =
'ProfilerStub';
80 if ( !is_array(
$params[
'output'] ) ) {
97 if ( self::$instance && !( self::$instance instanceof
ProfilerStub ) ) {
98 throw new MWException(
'Could not replace non-stub profiler instance.' );
100 self::$instance = $profiler;
108 $this->profileID = $id;
115 if ( $this->profileID ===
false ) {
139 if ( $this->context ) {
142 wfDebug( __METHOD__ .
" called and \$context is null. " .
143 "Return RequestContext::getMain(); for sanity\n" );
194 foreach ( $this->params[
'output']
as $outputType ) {
198 $outputClass = strpos( $outputType,
'ProfilerOutput' ) ===
false
199 ?
'ProfilerOutput' . ucfirst( $outputType )
201 if ( !class_exists( $outputClass ) ) {
202 throw new MWException(
"'$outputType' is an invalid output type" );
204 $outputInstance =
new $outputClass( $this, $this->params );
205 if ( $outputInstance->canUse() ) {
206 $outputs[] = $outputInstance;
220 $timeElapsed =
$request->getElapsedTime();
221 $timeElapsedThreshold = $this->params[
'threshold'];
222 if ( $timeElapsed <= $timeElapsedThreshold ) {
247 $output->log( $stats );
260 if ( preg_match(
'#^content-type: (\w+/\w+);?#i',
$header, $m ) ) {
273 $this->templated =
$t;
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.
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.
getRequest()
Get the WebRequest object.
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.
IContextSource $context
Current request context.
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)
array $params
All of the params passed from $wgProfiler.
profileIn( $functionname)
getContext()
Gets the context for this Profiler.
static getMain()
Static methods.
Subclass ScopedCallback to avoid call_user_func_array(), which is slow.
Helper class that detects high-contention DB queries via profiling calls.
when a variable name is used in a it is silently declared as a new local masking the global
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
the array() calling protocol came about after MediaWiki 1.4rc1.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object & $output
error also a ContextSource you ll probably need to make sure the header is varied on $request
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
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.