50 if ( isset( $params[
'profileID'] ) ) {
51 $this->profileID = $params[
'profileID'];
62 if ( self::$instance === null ) {
66 'class' =>
'ProfilerStub',
68 'threshold' => $wgProfileLimit,
71 if ( is_array( $wgProfiler ) ) {
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'] ) ) {
86 return self::$instance;
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" );
183 abstract public function close();
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 ) {
233 $output->log( $stats );
247 $output->log( $stats );
260 if ( preg_match(
'#^content-type: (\w+/\w+);?#i', $header, $m ) ) {
273 $this->templated =
$t;
getContext()
Gets the context for this Profiler.
string bool $profileID
Profiler ID for bucketing data.
the array() calling protocol came about after MediaWiki 1.4rc1.
static Profiler $instance
__construct(array $params)
getOutput()
Returns a profiling output to be stored in debug file.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
scopedProfileOut(SectionProfileCallback &$section=null)
IContextSource $context
Current request context.
static instance()
Singleton.
array $params
All of the params passed from $wgProfiler.
Stub profiler that does nothing.
setTemplated($t)
Mark this call as templated or not.
setContext($context)
Sets the context for this Profiler.
when a variable name is used in a it is silently declared as a new local masking the global
The least sophisticated profiler output class possible, view your source! :)
profileOut($functionname)
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
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.
static getMain()
Static methods.
Helper class that detects high-contention DB queries via profiling calls.
getOutputs()
Get all usable outputs.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
close()
Close opened profiling sections.
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
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
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
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
getTemplated()
Was this call as templated or not.
error also a ContextSource you ll probably need to make sure the header is varied on $request
logData()
Log the data to some store or even the page output.
Subclass ScopedCallback to avoid call_user_func_array(), which is slow.
logDataPageOutputOnly()
Output current data to the page output if configured to do so.
scopedProfileIn($section)
Mark the start of a custom profiling frame (e.g.
TransactionProfiler $trxProfiler
getFunctionStats()
Get the aggregated inclusive profiling data for each method.
getContentType()
Get the content type sent out to the client.
Profiler base class that defines the interface and some trivial functionality.