MediaWiki  REL1_31
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...
 
class  OutputHandler
 

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 (callable $postCommitWork=null)
 
 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', $blocksHttpClient=true)
 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 emitBufferedStatsdData (IBufferingStatsdDataFactory $stats, Config $config)
 Send out any buffered statsd data according to sampling rules. More...
 
static preOutputCommit (IContextSource $context, callable $postCommitWork=null)
 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 ()
 
 maybeDoHttpsRedirect ()
 If the stars are suitably aligned, do an HTTP->HTTPS redirect. More...
 
 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...
 
 setDBProfilingAgent ()
 
 shouldDoHttpRedirect ()
 Check if an HTTP->HTTPS redirect should be done. More...
 
 triggerAsyncJobs ( $n, LoggerInterface $runJobsLogger)
 
 triggerSyncJobs ( $n, LoggerInterface $runJobsLogger)
 
 tryNormaliseRedirect (Title $title)
 Handle redirects for uncanonical title requests. More...
 

Static Private Member Functions

static getUrlDomainDistance ( $url)
 

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 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, IContextSource\getConfig(), and RequestContext\getMain().

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, WebResponse\disableForPostSend(), Profiler\instance(), register_postsend_function(), restInPeace(), MWExceptionHandler\rollbackMasterChangesAndLog(), and use.

Referenced by run().

◆ doPreOutputCommit()

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

Definition at line 574 of file MediaWiki.php.

References preOutputCommit().

Referenced by main(), and run().

◆ emitBufferedStatsdData()

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

◆ getAction()

MediaWiki::getAction ( )

Returns the name of the action that will be executed.

Returns
string Action

Definition at line 154 of file MediaWiki.php.

References $action, and Action\getActionName().

Referenced by main(), and performAction().

◆ getTitle()

◆ getUrlDomainDistance()

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

Definition at line 689 of file MediaWiki.php.

References WikiMap\getWikiFromUrl(), and wfWikiID().

Referenced by preOutputCommit().

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

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

Referenced by performRequest().

◆ main()

◆ maybeDoHttpsRedirect()

MediaWiki::maybeDoHttpsRedirect ( )
private

If the stars are suitably aligned, do an HTTP->HTTPS redirect.

Note: Do this after $wgTitle is setup, otherwise the hooks run from isLoggedIn() will do all sorts of weird stuff.

Returns
bool True if the redirect was done. Handling of the request should be aborted. False if no redirect was done.

Definition at line 890 of file MediaWiki.php.

References $output, $request, $title, Title\newFromText(), NS_MAIN, Hooks\run(), shouldDoHttpRedirect(), and wfDebugLog().

Referenced by 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 $action, $request, $ret, $rev, $title, $wgContLang, 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().

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

References $action, $output, $request, $title, $user, Action\factory(), getAction(), Title\getCdnUrls(), Profiler\instance(), PROTO_INTERNAL, Hooks\run(), 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 174 of file MediaWiki.php.

References $article, $output, $query, $request, $title, $user, $wgTitle, SpecialPageFactory\executePath(), SpecialPageFactory\getPage(), SpecialPage\getTitleFor(), global, initializeArticle(), list, parseTitle(), performAction(), SpecialPageFactory\resolveAlias(), Hooks\run(), and tryNormaliseRedirect().

Referenced by main().

◆ preOutputCommit()

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

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

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

Definition at line 586 of file MediaWiki.php.

References $config, $context, $e, $options, $output, $request, DeferredUpdates\doUpdates(), Config\get(), IContextSource\getConfig(), MediaWiki\MediaWikiServices\getInstance(), IContextSource\getOutput(), IContextSource\getRequest(), getUrlDomainDistance(), MWExceptionHandler\logException(), DeferredUpdates\PRESEND, MessageCache\singleton(), wfDebug(), and wfDebugLog().

Referenced by doPreOutputCommit(), and ApiMain\executeActionWithErrorHandling().

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

References DeferredUpdates\addCallableUpdate(), class, DeferredUpdates\doUpdates(), MediaWiki\MediaWikiServices\getInstance(), Profiler\instance(), Wikimedia\Rdbms\ILBFactory\SHUTDOWN_NO_CHRONPROT, triggerJobs(), wfDebug(), and wfLogProfilingData().

Referenced by doPostOutputShutdown().

◆ run()

◆ setDBProfilingAgent()

MediaWiki::setDBProfilingAgent ( )
private

Definition at line 560 of file MediaWiki.php.

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

Referenced by run().

◆ shouldDoHttpRedirect()

MediaWiki::shouldDoHttpRedirect ( )
private

Check if an HTTP->HTTPS redirect should be done.

It may still be aborted by a hook, so this is not the final word.

Returns
bool

Definition at line 846 of file MediaWiki.php.

References $request, PROTO_HTTPS, and wfExpandUrl().

Referenced by maybeDoHttpsRedirect().

◆ triggerAsyncJobs()

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

Definition at line 1054 of file MediaWiki.php.

References $query, $req, $special, SpecialPageFactory\getPage(), SpecialRunJobs\getQuerySignature(), JobQueueGroup\singleton(), JobQueueGroup\TYPE_DEFAULT, 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 1002 of file MediaWiki.php.

References $e, getTitle(), MWExceptionHandler\logException(), 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 1044 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 $name, $output, $request, $title, SpecialPage\getTitleFor(), list, PROTO_CURRENT, SpecialPageFactory\resolveAlias(), Hooks\run(), 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.

Referenced by MediaWiki\Auth\AuthManager\fillRequests(), getAction(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProvider\getAuthenticationRequests(), MediaWiki\Auth\AuthPluginPrimaryAuthenticationProvider\getAuthenticationRequests(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider\getAuthenticationRequests(), MediaWiki\Auth\AuthManager\getAuthenticationRequests(), initializeArticle(), main(), parseTitle(), performAction(), run(), MediaWiki\Auth\AuthManagerTest\testGetAuthenticationRequests(), MediaWiki\Auth\EmailNotificationSecondaryAuthenticationProviderTest\testGetAuthenticationRequests(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProviderTest\testGetAuthenticationRequests(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest\testGetAuthenticationRequests(), MediaWiki\Auth\CheckBlocksSecondaryAuthenticationProviderTest\testGetAuthenticationRequests(), MediaWiki\Auth\ConfirmLinkSecondaryAuthenticationProviderTest\testGetAuthenticationRequests(), MediaWiki\Auth\ResetPasswordSecondaryAuthenticationProviderTest\testGetAuthenticationRequests(), MediaWiki\Auth\AuthPluginPrimaryAuthenticationProviderTest\testGetAuthenticationRequests(), MediaWiki\Auth\AuthManagerTest\testGetAuthenticationRequestsRequired(), MediaWiki\Auth\PasswordAuthenticationRequestTest\testGetFieldInfo2(), MediaWiki\Auth\PasswordDomainAuthenticationRequestTest\testGetFieldInfo2(), and MediaWiki\Preferences\DefaultPreferencesFactory\watchlistPreferences().

◆ $config

Config MediaWiki::$config
private

Definition at line 43 of file MediaWiki.php.

Referenced by MediaWiki\Auth\Throttler\__construct(), MediaWiki\Widget\ComplexTitleInputWidget\__construct(), MediaWiki\Widget\DateInputWidget\__construct(), MediaWiki\Widget\DateTimeInputWidget\__construct(), MediaWiki\Widget\NamespaceInputWidget\__construct(), MediaWiki\Widget\SearchInputWidget\__construct(), MediaWiki\Widget\SelectWithInputWidget\__construct(), MediaWiki\Widget\SizeFilterWidget\__construct(), MediaWiki\Widget\TitleInputWidget\__construct(), MediaWiki\Widget\UserInputWidget\__construct(), MediaWiki\Widget\UsersMultiselectWidget\__construct(), emitBufferedStatsdData(), MediaWiki\Tidy\BalanceElement\flatten(), MediaWiki\Widget\ComplexTitleInputWidget\getConfig(), MediaWiki\Widget\DateInputWidget\getConfig(), MediaWiki\Widget\DateTimeInputWidget\getConfig(), MediaWiki\Widget\NamespaceInputWidget\getConfig(), MediaWiki\Widget\SearchInputWidget\getConfig(), MediaWiki\Widget\SelectWithInputWidget\getConfig(), MediaWiki\Widget\SizeFilterWidget\getConfig(), MediaWiki\Widget\TitleInputWidget\getConfig(), MediaWiki\Widget\UserInputWidget\getConfig(), MediaWiki\Widget\UsersMultiselectWidget\getConfig(), MediaWiki\Auth\UserDataAuthenticationRequest\getFieldInfo(), MediaWiki\Widget\DateInputWidget\getInputElement(), MediaWiki\Widget\NamespaceInputWidget\getNamespaceDropdownOptions(), MediaWiki\Session\ImmutableSessionProviderWithCookieTest\getProvider(), MediaWiki\Auth\TemporaryPasswordAuthenticationRequest\newRandom(), preOutputCommit(), MediaWiki\Session\SessionProviderTest\testBasics(), MediaWiki\Auth\CheckBlocksSecondaryAuthenticationProviderTest\testConstructor(), MediaWiki\Auth\EmailNotificationSecondaryAuthenticationProviderTest\testConstructor(), MediaWiki\Auth\ThrottlePreAuthenticationProviderTest\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().

◆ $context

IContextSource MediaWiki::$context
private

Definition at line 38 of file MediaWiki.php.

Referenced by __construct(), MediaWiki\Shell\Command\__destruct(), MediaWiki\Preferences\DefaultPreferencesFactory\datetimePreferences(), MediaWiki\Logger\LegacyLogger\destination(), MediaWiki\Logger\Monolog\LogstashFormatter\fixKeyConflicts(), MediaWiki\Logger\LegacyLogger\format(), MediaWiki\Logger\LegacyLogger\formatAsWfDebug(), MediaWiki\Logger\Monolog\LogstashFormatter\formatV0(), MediaWiki\Logger\Monolog\LogstashFormatter\formatV1(), MediaWiki\Preferences\DefaultPreferencesFactory\generateSkinOptions(), MediaWiki\Preferences\DefaultPreferencesFactory\getDateOptions(), MediaWiki\Preferences\DefaultPreferencesFactory\getForm(), MediaWiki\Preferences\DefaultPreferencesFactory\getFormDescriptor(), MediaWiki\Preferences\DefaultPreferencesFactory\getTimezoneOptions(), MediaWiki\Logger\LegacyLogger\interpolate(), MediaWiki\Preferences\DefaultPreferencesFactory\loadPreferenceValues(), MediaWiki\Logger\ConsoleLogger\log(), MediaWiki\Logger\LegacyLogger\log(), MediaWiki\Auth\Throttler\logRejection(), preOutputCommit(), MediaWiki\Preferences\DefaultPreferencesFactory\profilePreferences(), run(), MediaWiki\Logger\LegacyLogger\shouldEmit(), MediaWiki\Preferences\DefaultPreferencesFactory\skinPreferences(), MediaWiki\Preferences\DefaultPreferencesFactory\submitForm(), MediaWiki\Session\SessionManagerTest\testGetGlobalSession(), MediaWiki\Logger\LegacyLoggerTest\testInterpolate(), MediaWiki\Auth\AuthManagerTest\testSetDefaultUserOptions(), MediaWiki\Logger\Monolog\KafkaHandler\warning(), and MediaWiki\Preferences\DefaultPreferencesFactory\watchlistPreferences().


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