MediaWiki  1.27.0
MediaWiki Class Reference

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

Collaboration diagram for MediaWiki:

Classes

class  MediaWikiServices
 MediaWikiServices is the service locator for the application scope of MediaWiki. More...
 

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. More...
 
 doPreOutputCommit ()
 
 getAction ()
 Returns the name of the action that will be executed. More...
 
 getTitle ()
 Get the Title object that we'll be acting on, as specified in the WebRequest. More...
 
 restInPeace ($mode= 'fast')
 Ends this task peacefully. More...
 
 run ()
 Run the current MediaWiki instance; index.php just calls this. More...
 
 triggerJobs ()
 Potentially open a socket and sent an HTTP request back to the server to run a specified number of jobs. More...
 

Static Public Member Functions

static preOutputCommit (IContextSource $context)
 This function commits all DB changes as needed before the user can receive a response (in case commit fails) More...
 

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. More...
 
 main ()
 
 parseTitle ()
 Parse the request to get the Title object. More...
 
 performAction (Page $page, Title $requestTitle)
 Perform one of the "standard" actions. More...
 
 performRequest ()
 Performs the request. More...
 
 tryNormaliseRedirect (Title $title)
 Handle redirects for uncanonical title requests. More...
 

Private Attributes

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

Detailed Description

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

Definition at line 28 of file MediaWiki.php.

Constructor & Destructor Documentation

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

Definition at line 47 of file MediaWiki.php.

References $context, IContextSource\getConfig(), and RequestContext\getMain().

Member Function Documentation

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 607 of file MediaWiki.php.

References $e, MWExceptionHandler\handleException(), Profiler\instance(), and use.

Referenced by run().

MediaWiki::doPreOutputCommit ( )
See also
MediaWiki::preOutputCommit()
Since
1.26

Definition at line 538 of file MediaWiki.php.

Referenced by main(), and run().

MediaWiki::getAction ( )

Returns the name of the action that will be executed.

Returns
string Action

Definition at line 148 of file MediaWiki.php.

References $action, action, and Action\getActionName().

Referenced by main(), and performAction().

MediaWiki::getTitle ( )

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

Returns
Title

Definition at line 132 of file MediaWiki.php.

References SpecialPage\getTitleFor(), and parseTitle().

Referenced by main(), and triggerJobs().

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 386 of file MediaWiki.php.

References $article, $page, $request, $title, WikiPage\factory(), ContentHandler\getForTitle(), ContextSource\getRequest(), Article\newFromWikiPage(), Hooks\run(), and wfWarn().

Referenced by performRequest().

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 62 of file MediaWiki.php.

References $request, $ret, $rev, $title, $wgContLang, ContextSource\getRequest(), SpecialPage\getTitleFor(), global, Title\makeTitle(), Revision\newFromId(), Title\newFromID(), Title\newFromTextThrow(), Title\newFromURL(), Title\newMainPage(), NS_FILE, and NS_MEDIA.

Referenced by getTitle(), and performRequest().

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 469 of file MediaWiki.php.

References $output, $page, $request, $title, $user, Action\factory(), getAction(), Title\getCdnUrls(), ContextSource\getRequest(), Profiler\instance(), PROTO_INTERNAL, Hooks\run(), and wfExpandUrl().

Referenced by 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 168 of file MediaWiki.php.

References $article, $output, $query, $request, $title, $user, $wgTitle, action, ParserOutput\addJsConfigVars(), ParserOutput\addModules(), SpecialPageFactory\executePath(), ContextSource\getOutput(), SpecialPageFactory\getPage(), ContextSource\getRequest(), SpecialPage\getTitleFor(), global, initializeArticle(), list, NS_SPECIAL, parseTitle(), performAction(), SpecialPageFactory\resolveAlias(), Hooks\run(), and tryNormaliseRedirect().

Referenced by main().

static MediaWiki::preOutputCommit ( IContextSource  $context)
static

This function commits all DB changes as needed before the user can receive a response (in case commit fails)

Parameters
IContextSource$context
Since
1.27

Definition at line 549 of file MediaWiki.php.

References $factory, $options, $request, DeferredUpdates\doUpdates(), Config\get(), IContextSource\getConfig(), IContextSource\getOutput(), IContextSource\getRequest(), DeferredUpdates\PRESEND, MessageCache\singleton(), wfDebug(), wfDebugLog(), and wfGetLBFactory().

Referenced by ApiMain\executeActionWithErrorHandling().

MediaWiki::restInPeace (   $mode = 'fast')

Ends this task peacefully.

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

Definition at line 760 of file MediaWiki.php.

References $factory, DeferredUpdates\doUpdates(), Profiler\instance(), JobQueueGroup\pushLazyJobs(), LBFactory\SHUTDOWN_NO_CHRONPROT, triggerJobs(), wfDebug(), wfGetLBFactory(), and wfLogProfilingData().

MediaWiki::run ( )

Run the current MediaWiki instance; index.php just calls this.

Definition at line 516 of file MediaWiki.php.

References $e, doPostOutputShutdown(), doPreOutputCommit(), MWExceptionHandler\handleException(), main(), and ErrorPageError\report().

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 796 of file MediaWiki.php.

References $e, $query, $req, $status, SpecialRunJobs\getQuerySignature(), getTitle(), MWExceptionHandler\logException(), JobQueueGroup\singleton(), JobQueueGroup\TYPE_DEFAULT, wfAppendQuery(), wfParseUrl(), wfReadOnly(), and wfScript().

Referenced by restInPeace().

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
  • Normalise non-standard title urls: /w/index.php?title=Foo_Bar -> /wiki/Foo_Bar
  • 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 323 of file MediaWiki.php.

References $name, $output, $request, Title\getDBkey(), Title\getFullURL(), Title\getPrefixedDBkey(), ContextSource\getRequest(), SpecialPage\getTitleFor(), Title\isSpecialPage(), list, PROTO_CURRENT, SpecialPageFactory\resolveAlias(), Hooks\run(), and wfExpandUrl().

Referenced by performRequest().

Member Data Documentation

Config MediaWiki::$config
private

Definition at line 37 of file MediaWiki.php.

Referenced by MediaWiki\Widget\UserInputWidget\__construct(), MediaWiki\Widget\NamespaceInputWidget\__construct(), MediaWiki\Widget\ComplexTitleInputWidget\__construct(), MediaWiki\Widget\SearchInputWidget\__construct(), MediaWiki\Widget\TitleInputWidget\__construct(), MediaWiki\Auth\Throttler\__construct(), MediaWiki\Widget\NamespaceInputWidget\getConfig(), MediaWiki\Widget\TitleInputWidget\getConfig(), MediaWiki\Widget\SearchInputWidget\getConfig(), MediaWiki\Widget\ComplexTitleInputWidget\getConfig(), MediaWiki\Auth\UserDataAuthenticationRequest\getFieldInfo(), MediaWiki\Session\ImmutableSessionProviderWithCookieTest\getProvider(), MediaWiki\Auth\TemporaryPasswordAuthenticationRequest\newRandom(), MediaWiki\Session\SessionProviderTest\testBasics(), MediaWiki\Auth\EmailNotificationSecondaryAuthenticationProviderTest\testConstructor(), MediaWiki\Auth\ThrottlePreAuthenticationProviderTest\testConstructor(), MediaWiki\Auth\CheckBlocksSecondaryAuthenticationProviderTest\testConstructor(), MediaWiki\Session\CookieSessionProviderTest\testConstructor(), MediaWiki\Auth\ConfirmLinkSecondaryAuthenticationProviderTest\testContinueLinkAttempt(), MediaWiki\Session\CookieSessionProviderTest\testCookieData(), MediaWiki\Session\CookieSessionProviderTest\testGetLoginCookieExpiration(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest\testGetNewPasswordExpiry(), MediaWiki\Session\CookieSessionProviderTest\testGetRememberUserDuration(), MediaWiki\Session\SessionProviderTest\testHashToSessionId(), MediaWiki\Session\CookieSessionProviderTest\testPersistSession(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest\testSetPasswordResetFlag(), MediaWiki\Logger\LegacyLoggerTest\testShouldEmit(), and MediaWiki\Auth\ResetPasswordSecondaryAuthenticationProviderTest\testTryReset().


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