MediaWiki REL1_33
MediaWiki Class Reference

The MediaWiki class is the helper class for the index.php entry point. More...

Collaboration diagram for MediaWiki:

Public Member Functions

 __construct (IContextSource $context=null)
 
 doPostOutputShutdown ( $mode='normal')
 This function does work that can be done after the user gets the HTTP response so they don't block on it.
 
 doPreOutputCommit (callable $postCommitWork=null)
 
 getAction ()
 Returns the name of the action that will be executed.
 
 getTitle ()
 Get the Title object that we'll be acting on, as specified in the WebRequest.
 
 restInPeace ( $mode='fast', $blocksHttpClient=true)
 Ends this task peacefully.
 
 run ()
 Run the current MediaWiki instance; index.php just calls this.
 
 triggerJobs ()
 Potentially open a socket and sent an HTTP request back to the server to run a specified number of jobs.
 

Static Public Member Functions

static emitBufferedStatsdData (IBufferingStatsdDataFactory $stats, Config $config)
 Send out any buffered statsd data according to sampling rules.
 
static preOutputCommit (IContextSource $context, callable $postCommitWork=null)
 This function commits all DB and session changes as needed before the client can receive a response (in case DB commit fails) and thus also before the response can trigger a subsequent related request by the client.
 

Private Member Functions

 initializeArticle ()
 Initialize the main Article object for "standard" actions (view, etc) Create an Article object for the page, following redirects if needed.
 
 main ()
 
 parseTitle ()
 Parse the request to get the Title object.
 
 performAction (Page $page, Title $requestTitle)
 Perform one of the "standard" actions.
 
 performRequest ()
 Performs the request.
 
 setDBProfilingAgent ()
 
 triggerAsyncJobs ( $n, LoggerInterface $runJobsLogger)
 
 triggerSyncJobs ( $n, LoggerInterface $runJobsLogger)
 
 tryNormaliseRedirect (Title $title)
 Handle redirects for uncanonical title requests.
 

Static Private Member Functions

static getUrlDomainDistance ( $url)
 

Private Attributes

string $action
 Cache what action this request is.
 
Config $config
 
IContextSource $context
 

Detailed Description

The MediaWiki class is the helper class for the index.php entry point.

Definition at line 34 of file MediaWiki.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki::__construct ( IContextSource $context = null)
Parameters
IContextSource | null$context

Definition at line 53 of file MediaWiki.php.

References $context.

Member Function Documentation

◆ doPostOutputShutdown()

MediaWiki::doPostOutputShutdown ( $mode = 'normal')

This function does work that can be done after the user gets the HTTP response so they don't block on it.

This manages deferred updates, job insertion, final commit, and the logging of profiling data

Parameters
string$modeUse 'fast' to always skip job running
Since
1.26

Definition at line 710 of file MediaWiki.php.

References $e, and(), WebResponse\disableForPostSend(), and restInPeace().

Referenced by run().

◆ doPreOutputCommit()

MediaWiki::doPreOutputCommit ( callable $postCommitWork = null)
See also
MediaWiki::preOutputCommit()
Parameters
callable | null$postCommitWork[default: null]
Since
1.26

Definition at line 565 of file MediaWiki.php.

Referenced by main(), and run().

◆ emitBufferedStatsdData()

static MediaWiki::emitBufferedStatsdData ( IBufferingStatsdDataFactory $stats,
Config $config )
static

Send out any buffered statsd data according to sampling rules.

Parameters
IBufferingStatsdDataFactory$stats
Config$config
Exceptions
ConfigException
Since
1.31

Definition at line 933 of file MediaWiki.php.

References IBufferingStatsdDataFactory\clearData(), Config\get(), IBufferingStatsdDataFactory\getData(), and IBufferingStatsdDataFactory\hasData().

◆ getAction()

MediaWiki::getAction ( )

Returns the name of the action that will be executed.

Returns
string Action

Definition at line 153 of file MediaWiki.php.

Referenced by main(), and performAction().

◆ getTitle()

MediaWiki::getTitle ( )

Get the Title object that we'll be acting on, as specified in the WebRequest.

Returns
Title

Definition at line 137 of file MediaWiki.php.

References parseTitle().

Referenced by main(), and triggerJobs().

◆ getUrlDomainDistance()

static MediaWiki::getUrlDomainDistance ( $url)
staticprivate
Parameters
string$url
Returns
string Either "local", "remote" if in the farm, "external" otherwise

Definition at line 688 of file MediaWiki.php.

◆ initializeArticle()

MediaWiki::initializeArticle ( )
private

Initialize the main Article object for "standard" actions (view, etc) Create an Article object for the page, following redirects if needed.

Returns
Article|string An Article, or a string to redirect to another URL

Definition at line 383 of file MediaWiki.php.

References $article, $request, and(), Article\newFromWikiPage(), and wfWarn().

Referenced by performRequest().

◆ main()

◆ parseTitle()

MediaWiki::parseTitle ( )
private

Parse the request to get the Title object.

Exceptions
MalformedTitleExceptionIf a title has been provided by the user, but is invalid.
Returns
Title Title object to be $wgTitle

Definition at line 68 of file MediaWiki.php.

References $request, $ret, $rev, and(), MediaWiki\MediaWikiServices\getInstance(), Revision\newFromId(), NS_FILE, and NS_MEDIA.

Referenced by getTitle(), and performRequest().

◆ performAction()

MediaWiki::performAction ( Page $page,
Title $requestTitle )
private

Perform one of the "standard" actions.

Parameters
Page$page
Title$requestTitleThe original title, before any redirects were applied

Definition at line 464 of file MediaWiki.php.

References $output, $request, getAction(), PROTO_INTERNAL, and wfExpandUrl().

Referenced by performRequest().

◆ performRequest()

MediaWiki::performRequest ( )
private

Performs the request.

  • bad titles
  • read restriction
  • local interwiki redirects
  • redirect loop
  • special pages
  • normal pages
Exceptions
MWException|PermissionsError|BadTitleError|HttpError
Returns
void

Definition at line 173 of file MediaWiki.php.

References $article, $output, $query, $request, $wgTitle, and(), MediaWiki\MediaWikiServices\getInstance(), initializeArticle(), list, parseTitle(), performAction(), and tryNormaliseRedirect().

Referenced by main().

◆ preOutputCommit()

static MediaWiki::preOutputCommit ( IContextSource $context,
callable $postCommitWork = null )
static

This function commits all DB and session changes as needed before the client can receive a response (in case DB commit fails) and thus also before the response can trigger a subsequent related request by the client.

If there is a significant amount of content to flush, it can be done in $postCommitWork

Parameters
IContextSource$context
callable | null$postCommitWork[default: null]
Since
1.27

Definition at line 580 of file MediaWiki.php.

References $context, $e, $options, $output, $request, $value, and(), Config\get(), MediaWiki\MediaWikiServices\getInstance(), wfDebug(), and wfDebugLog().

◆ restInPeace()

MediaWiki::restInPeace ( $mode = 'fast',
$blocksHttpClient = true )

Ends this task peacefully.

Parameters
string$modeUse 'fast' to always skip job running
bool$blocksHttpClientWhether this blocks an HTTP response to a client

Definition at line 892 of file MediaWiki.php.

References and(), MediaWiki\MediaWikiServices\getInstance(), triggerJobs(), wfDebug(), and wfLogProfilingData().

Referenced by doPostOutputShutdown().

◆ run()

MediaWiki::run ( )

◆ setDBProfilingAgent()

MediaWiki::setDBProfilingAgent ( )
private

Definition at line 551 of file MediaWiki.php.

References $name, $services, and(), and MediaWiki\MediaWikiServices\getInstance().

Referenced by run().

◆ triggerAsyncJobs()

MediaWiki::triggerAsyncJobs ( $n,
LoggerInterface $runJobsLogger )
private
Parameters
int$nNumber of jobs to try to run
LoggerInterface$runJobsLogger
Returns
bool Success

Definition at line 1016 of file MediaWiki.php.

References $query, $req, and(), MediaWiki\MediaWikiServices\getInstance(), SpecialRunJobs\getQuerySignature(), and wfParseUrl().

Referenced by triggerJobs().

◆ triggerJobs()

MediaWiki::triggerJobs ( )

Potentially open a socket and sent an HTTP request back to the server to run a specified number of jobs.

This registers a callback to cleanup the socket once it's done.

Definition at line 958 of file MediaWiki.php.

References $e, and(), getTitle(), triggerAsyncJobs(), triggerSyncJobs(), and wfReadOnly().

Referenced by restInPeace().

◆ triggerSyncJobs()

MediaWiki::triggerSyncJobs ( $n,
LoggerInterface $runJobsLogger )
private
Parameters
int$nNumber of jobs to try to run
LoggerInterface$runJobsLogger

Definition at line 1000 of file MediaWiki.php.

Referenced by triggerJobs().

◆ tryNormaliseRedirect()

MediaWiki::tryNormaliseRedirect ( Title $title)
private

Handle redirects for uncanonical title requests.

Handles:

  • Redirect loops.
  • No title in URL.
  • $wgUsePathInfo URLs.
  • URLs with a variant.
  • Other non-standard URLs (as long as they have no extra query parameters).

Behaviour:

  • Normalise title values: /wiki/Foo%20Bar -> /wiki/Foo_Bar
  • Normalise empty title: /wiki/ -> /wiki/Main /w/index.php?title= -> /wiki/Main
  • Don't redirect anything with query parameters other than 'title' or 'action=view'.
Parameters
Title$title
Returns
bool True if a redirect was set.
Exceptions
HttpError

Definition at line 327 of file MediaWiki.php.

References $output, $request, MediaWiki\MediaWikiServices\getInstance(), list, PROTO_CURRENT, and wfExpandUrl().

Referenced by performRequest().

Member Data Documentation

◆ $action

string MediaWiki::$action
private

Cache what action this request is.

Definition at line 48 of file MediaWiki.php.

◆ $config

Config MediaWiki::$config
private

Definition at line 43 of file MediaWiki.php.

◆ $context

IContextSource MediaWiki::$context
private

Definition at line 38 of file MediaWiki.php.


The documentation for this class was generated from the following file: