MediaWiki master
MediaWiki\Context\ContextSource Class Reference

The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and provide accessors to it. More...

Inherits MediaWiki\Context\IContextSource.

Inherited by ApiBase, ApiModuleManager, ChangesList, DifferenceEngine, FormatMetadata, ImageGalleryBase, ImageHistoryList, ImportReporter, LogEventsList, LoginHelper, MediaWiki\Category\CategoryViewer, MediaWiki\Context\DerivativeContext, MediaWiki\HTMLForm\HTMLForm, MediaWiki\Output\OutputPage, MediaWiki\Pager\IndexPager, RevisionListBase, and Skin.

Collaboration diagram for MediaWiki\Context\ContextSource:

Public Member Functions

 canUseWikiPage ()
 Check whether a WikiPage object can be get with getWikiPage().
 
 exportSession ()
 Export the resolved user IP, HTTP headers, user ID, and session ID.
 
 getActionName ()
 Get the action name for the current web request.
 
 getAuthority ()
 
 getConfig ()
 
 getContext ()
 Get the base IContextSource object.
 
 getCsrfTokenSet ()
 Get a repository to obtain and match CSRF tokens.
 
 getLanguage ()
 
 getLanguageCode ()
 
 getOutput ()
 
 getRequest ()
 
 getSkin ()
 
 getTiming ()
 
 getTitle ()
 
 getUser ()
 
 getWikiPage ()
 Get the WikiPage object.
 
 msg ( $key,... $params)
 Get a Message object with context set Parameters are the same as wfMessage()
 
 setContext (IContextSource $context)
 

Detailed Description

The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and provide accessors to it.

Stability: stable
to extend
Since
1.18
Author
Happy-melon

Definition at line 47 of file ContextSource.php.

Member Function Documentation

◆ canUseWikiPage()

MediaWiki\Context\ContextSource::canUseWikiPage ( )

Check whether a WikiPage object can be get with getWikiPage().

Callers should expect that an exception is thrown from getWikiPage() if this method returns false.

Since
1.19
Stability: stable
to override
Returns
bool

Implements MediaWiki\Context\IContextSource.

Reimplemented in MediaWiki\Context\DerivativeContext.

Definition at line 117 of file ContextSource.php.

References MediaWiki\Context\ContextSource\getContext().

◆ exportSession()

MediaWiki\Context\ContextSource::exportSession ( )

Export the resolved user IP, HTTP headers, user ID, and session ID.

The result will be reasonably sized to allow for serialization.

Since
1.21
Stability: stable
to override
Returns
array

Implements MediaWiki\Context\IContextSource.

Definition at line 233 of file ContextSource.php.

References getContext().

◆ getActionName()

MediaWiki\Context\ContextSource::getActionName ( )

Get the action name for the current web request.

Since
1.38
Stability: stable
to override
Returns
string

Implements MediaWiki\Context\IContextSource.

Reimplemented in MediaWiki\Context\DerivativeContext.

Definition at line 142 of file ContextSource.php.

◆ getAuthority()

MediaWiki\Context\ContextSource::getAuthority ( )
Since
1.36
Returns
Authority

Implements MediaWiki\Context\IContextSource.

Reimplemented in MediaWiki\Context\DerivativeContext.

Definition at line 169 of file ContextSource.php.

Referenced by MediaWiki\Pager\HistoryPager\__construct(), MediaWiki\Pager\UsersPager\canSeeHideuser(), MediaWiki\Pager\HistoryPager\doBatchLookups(), MediaWiki\Pager\DeletedContribsPager\doBatchLookups(), ApiAMCreateAccount\execute(), ApiBlock\execute(), ApiChangeContentModel\execute(), ApiEditPage\execute(), ApiFileRevert\execute(), ApiImageRotate\execute(), ApiImport\execute(), ApiManageTags\execute(), ApiMove\execute(), ApiPatrol\execute(), ApiProtect\execute(), ApiPurge\execute(), ApiQueryBlocks\execute(), ApiQueryDeletedrevs\execute(), ApiQueryFilearchive\execute(), ApiQueryImageInfo\execute(), ApiQueryLogEvents\execute(), ApiRevisionDelete\execute(), ApiRollback\execute(), ApiSetPageLanguage\execute(), ApiTag\execute(), ApiUnblock\execute(), ApiUserrights\execute(), ApiFeedContributions\feedItem(), MediaWiki\Pager\HistoryPager\formatRow(), MediaWiki\Pager\NewPagesPager\formatRow(), MediaWiki\Pager\ProtectedPagesPager\formatValue(), MediaWiki\Pager\BlockListPager\formatValue(), ImageHistoryPseudoPager\getBody(), ApiQueryLogEvents\getCacheMode(), ApiQueryUserInfo\getCurrentUserInfo(), MediaWiki\Pager\BlockListPager\getQueryInfo(), MediaWiki\Pager\DeletedContribsPager\getQueryInfo(), MediaWiki\Pager\HistoryPager\getStartBody(), ApiMergeHistory\merge(), ApiMove\moveSubpages(), and ApiTag\processIndividual().

◆ getConfig()

MediaWiki\Context\ContextSource::getConfig ( )
Since
1.23
Stability: stable
to override
Returns
Config

Implements MediaWiki\Context\IContextSource.

Reimplemented in MediaWiki\Context\DerivativeContext.

Definition at line 86 of file ContextSource.php.

References MediaWiki\Context\ContextSource\getContext().

Referenced by ApiMain\__construct(), ImageGalleryBase\__construct(), ApiBlock\__construct(), ApiUnblock\__construct(), ApiQuery\__construct(), ApiEditPage\__construct(), ApiUpload\__construct(), ApiMove\__construct(), ApiDelete\__construct(), ApiRollback\__construct(), ApiUserrights\__construct(), ApiWatch\__construct(), ApiProtect\__construct(), ApiUndelete\__construct(), ApiQueryBlocks\__construct(), ApiQueryQueryPage\__construct(), MediaWiki\Pager\HistoryPager\__construct(), MediaWiki\Pager\BlockListPager\__construct(), MediaWiki\Pager\UsersPager\__construct(), MediaWiki\Pager\ActiveUsersPager\__construct(), UploadForm\addUploadJS(), ApiQuerySiteinfo\appendAutoCreateTempUser(), ApiQuerySiteinfo\appendDbReplLagInfo(), ApiQuerySiteinfo\appendExtensions(), ApiQuerySiteinfo\appendFileExtensions(), ApiQuerySiteinfo\appendGeneralInfo(), ApiQuerySiteinfo\appendInterwikiMap(), ApiQuerySiteinfo\appendNamespaces(), ApiQuerySiteinfo\appendProtocols(), ApiQuerySiteinfo\appendRestrictions(), ApiQuerySiteinfo\appendRightsInfo(), ApiQuerySiteinfo\appendUploadDialog(), ApiQuerySiteinfo\appendUserGroups(), MediaWiki\Output\OutputPage\checkLastModified(), ApiBlock\execute(), ApiEditPage\execute(), ApiEmailUser\execute(), ApiFeedContributions\execute(), ApiFeedRecentChanges\execute(), ApiFeedWatchlist\execute(), ApiLogin\execute(), ApiOpenSearch\execute(), ApiQueryAllUsers\execute(), ApiQueryAuthManagerInfo\execute(), ApiQueryBlocks\execute(), ApiQueryFileRepoInfo\execute(), ApiQueryLangLinks\execute(), ApiQueryLogEvents\execute(), ApiQueryUserContribs\execute(), ApiQueryUsers\execute(), ApiRemoveAuthenticationData\execute(), ApiRollback\execute(), ApiSetPageLanguage\execute(), ApiUpload\execute(), MediaWiki\Pager\UsersPager\formatRow(), ApiImport\getAllowedImportSources(), ApiFeedWatchlist\getAllowedParams(), ApiQueryAllUsers\getAllowedParams(), ApiQueryLogEvents\getAllowedParams(), ApiBlock\getAllowedParams(), ApiFeedContributions\getAllowedParams(), ApiFeedRecentChanges\getAllowedParams(), ApiOpenSearch\getAllowedParams(), ApiQueryAllDeletedRevisions\getAllowedParams(), ApiQueryAllImages\getAllowedParams(), ApiQueryAllPages\getAllowedParams(), ApiQueryAllRevisions\getAllowedParams(), ApiQueryBacklinksprop\getAllowedParams(), ApiQueryBlocks\getAllowedParams(), ApiQueryCategoryMembers\getAllowedParams(), ApiQueryExtLinksUsage\getAllowedParams(), ApiQueryProtectedTitles\getAllowedParams(), ApiQueryUserContribs\getAllowedParams(), ApiResetPassword\getAllowedParams(), ApiQuerySiteinfo\getCacheMode(), ApiQueryUserInfo\getCurrentUserInfo(), UploadForm\getDescriptionSection(), ApiResetPassword\getExamplesMessages(), ApiLogin\getExtendedDescription(), ApiSetPageLanguage\getExtendedDescription(), UploadForm\getExtensionsMessage(), MediaWiki\Pager\ImageListPager\getFieldNames(), MediaWiki\Pager\LogPager\getFilterParams(), MediaWiki\Category\CategoryViewer\getHTML(), EnhancedChangesList\getLineData(), ApiPageSet\getPageTableFields(), MediaWiki\Pager\ActiveUsersPager\getQueryInfo(), MediaWiki\Pager\LogPager\getQueryInfo(), ApiQueryUserInfo\getRateLimits(), UploadForm\getSourceSection(), SkinFallback\getTemplateData(), ApiFormatBase\initPrinter(), ApiLogin\isDeprecated(), MediaWiki\Pager\ImageListPager\isFieldSortable(), ApiQueryImageInfo\mergeThumbParams(), SkinTemplate\prepareQuickTemplate(), MediaWiki\Pager\ContribsPager\reallyDoQuery(), EnhancedChangesList\recentChangesBlockGroup(), EnhancedChangesList\recentChangesBlockLine(), ChangesList\recentChangesFlags(), ApiQueryInfo\requestExtraData(), ApiQueryRecentChanges\run(), ApiQueryAllDeletedRevisions\run(), ApiQueryAllRevisions\run(), SkinTemplate\setupTemplate(), LogEventsList\showOptions(), LoginHelper\showReturnToPage(), TraditionalImageGallery\toHTML(), and SkinTemplate\useCombinedLoginLink().

◆ getContext()

MediaWiki\Context\ContextSource::getContext ( )

Get the base IContextSource object.

Since
1.18
Stability: stable
to override
Returns
IContextSource

Definition at line 61 of file ContextSource.php.

References MediaWiki\Context\RequestContext\getMain(), and wfDebug().

Referenced by ApiBase\__construct(), RevisionItem\__construct(), MediaWiki\Pager\UsersPager\buildGroupLink(), MediaWiki\Context\ContextSource\canUseWikiPage(), MediaWiki\Context\DerivativeContext\canUseWikiPage(), MediaWiki\Category\CategoryViewer\clearCategoryState(), MediaWiki\Specials\SpecialUnblock\execute(), ApiChangeContentModel\execute(), ApiComparePages\execute(), ApiEmailUser\execute(), ApiExpandTemplates\execute(), ApiFeedContributions\execute(), ApiRevisionDelete\execute(), ApiUserrights\execute(), ApiFeedContributions\feedItem(), MediaWiki\Pager\HistoryPager\formatRow(), MediaWiki\Pager\ProtectedTitlesPager\formatRow(), MediaWiki\Pager\ProtectedPagesPager\formatValue(), MediaWiki\Context\ContextSource\getConfig(), MediaWiki\Context\DerivativeContext\getConfig(), ApiAMCreateAccount\getFinalDescription(), ApiClientLogin\getFinalDescription(), ApiLinkAccount\getFinalDescription(), MediaWiki\Pager\UsersPager\getPageHeader(), MediaWiki\Context\ContextSource\getRequest(), MediaWiki\Context\DerivativeContext\getRequest(), MediaWiki\Pager\NewFilesPager\getStartBody(), MediaWiki\Pager\CategoryPager\getStartForm(), MediaWiki\Context\DerivativeContext\getTiming(), MediaWiki\Context\ContextSource\getTitle(), MediaWiki\Context\DerivativeContext\getTitle(), MediaWiki\Context\ContextSource\getWikiPage(), MediaWiki\Context\DerivativeContext\getWikiPage(), MediaWiki\Specials\SpecialTags\processCreateTagForm(), MediaWiki\Specials\SpecialTags\processTagForm(), MediaWiki\Preferences\DefaultPreferencesFactory\saveFormData(), MediaWiki\Specials\SpecialComparePages\showDiff(), MediaWiki\Preferences\DefaultPreferencesFactory\submitForm(), and MediaWiki\Preferences\DefaultPreferencesFactory\validateSignature().

◆ getCsrfTokenSet()

MediaWiki\Context\ContextSource::getCsrfTokenSet ( )

Get a repository to obtain and match CSRF tokens.

Returns
CsrfTokenSet
Since
1.37

Implements MediaWiki\Session\CsrfTokenSetProvider.

Definition at line 243 of file ContextSource.php.

◆ getLanguage()

MediaWiki\Context\ContextSource::getLanguage ( )

◆ getLanguageCode()

MediaWiki\Context\ContextSource::getLanguageCode ( )
Since
1.42
Stability: stable
to override
Note
When overriding, keep consistent with getLanguage()!
Returns
Bcp47Code

Implements MediaWiki\Language\LocalizationContext.

Definition at line 188 of file ContextSource.php.

◆ getOutput()

◆ getRequest()

◆ getSkin()

MediaWiki\Context\ContextSource::getSkin ( )
Since
1.18
Stability: stable
to override
Returns
Skin

Implements MediaWiki\Context\IContextSource.

Reimplemented in MediaWiki\Context\DerivativeContext.

Definition at line 197 of file ContextSource.php.

References getContext().

◆ getTiming()

MediaWiki\Context\ContextSource::getTiming ( )
Since
1.27
Stability: stable
to override
Returns
Timing

Implements MediaWiki\Context\IContextSource.

Reimplemented in MediaWiki\Context\DerivativeContext.

Definition at line 206 of file ContextSource.php.

References getContext().

◆ getTitle()

◆ getUser()

MediaWiki\Context\ContextSource::getUser ( )
Stability: stable
to override
Since
1.18
Stability: stable
to override
Returns
User

Implements MediaWiki\Context\IContextSource.

Reimplemented in MediaWiki\Context\DerivativeContext.

Definition at line 161 of file ContextSource.php.

References getContext().

Referenced by ImageHistoryPseudoPager\__construct(), MediaWiki\Pager\HistoryPager\__construct(), MediaWiki\Pager\IndexPager\__construct(), MediaWiki\Output\OutputPage\checkLastModified(), MediaWiki\Specials\SpecialUnblock\execute(), ApiAcquireTempUserName\execute(), ApiBlock\execute(), ApiChangeAuthenticationData\execute(), ApiCheckToken\execute(), ApiClearHasMsg\execute(), ApiCSPReport\execute(), ApiDelete\execute(), ApiEditPage\execute(), ApiEmailUser\execute(), ApiLinkAccount\execute(), ApiLogout\execute(), ApiMove\execute(), ApiPatrol\execute(), ApiProtect\execute(), ApiQueryAuthManagerInfo\execute(), ApiQueryDeletedrevs\execute(), ApiQueryFilearchive\execute(), ApiQueryMyStashedFiles\execute(), ApiQueryTokens\execute(), ApiRemoveAuthenticationData\execute(), ApiResetPassword\execute(), ApiRevisionDelete\execute(), ApiRollback\execute(), ApiSetNotificationTimestamp\execute(), ApiStashEdit\execute(), ApiTag\execute(), ApiUnblock\execute(), ApiUndelete\execute(), ApiUpload\execute(), ApiUserrights\execute(), ApiWatch\execute(), MediaWiki\Pager\MergeHistoryPager\formatRow(), MediaWiki\Pager\NewPagesPager\formatRow(), MediaWiki\Pager\ProtectedTitlesPager\formatRow(), MediaWiki\Pager\UsersPager\formatRow(), MediaWiki\Pager\ProtectedPagesPager\formatValue(), MediaWiki\Pager\UploadStashPager\formatValue(), ApiQueryUserInfo\getCurrentUserInfo(), ApiQueryUserInfo\getLatestContributionTime(), MediaWiki\Pager\UploadStashPager\getQueryInfo(), ApiQueryUserInfo\getRateLimits(), ApiTag\processIndividual(), MediaWiki\HTMLForm\HTMLForm\tryAuthorizedSubmit(), and MediaWiki\Preferences\DefaultPreferencesFactory\validateSignature().

◆ getWikiPage()

MediaWiki\Context\ContextSource::getWikiPage ( )

Get the WikiPage object.

May throw an exception if there's no Title object set or the Title object belongs to a special namespace that doesn't have WikiPage, so use first canUseWikiPage() to check whether this method can be called safely.

Since
1.19
Stability: stable
to override
Returns
WikiPage

Implements MediaWiki\Context\IContextSource.

Reimplemented in MediaWiki\Context\DerivativeContext.

Definition at line 131 of file ContextSource.php.

References MediaWiki\Context\ContextSource\getContext().

Referenced by MediaWiki\Pager\HistoryPager\formatRow(), and MediaWiki\Pager\HistoryPager\getQueryInfo().

◆ msg()

MediaWiki\Context\ContextSource::msg ( $key,
$params )

Get a Message object with context set Parameters are the same as wfMessage()

Since
1.18
Stability: stable
to override
Parameters
string | string[] | MessageSpecifier$keyMessage key, or array of keys, or a MessageSpecifier.
mixed...$params
Returns
Message

Implements MessageLocalizer.

Reimplemented in MediaWiki\Context\DerivativeContext.

Definition at line 221 of file ContextSource.php.

References $params, and getContext().

Referenced by UploadForm\__construct(), MediaWiki\Pager\ContribsPager\__construct(), MediaWiki\Pager\DeletedContribsPager\__construct(), ApiQuerySiteinfo\appendInterwikiMap(), ApiQuerySiteinfo\appendSkins(), ImageHistoryList\beginImageHistoryList(), SkinTemplate\buildLoginData(), SkinTemplate\buildPersonalUrls(), ImportReporter\close(), ApiFormatBase\closePrinter(), ApiAMCreateAccount\execute(), ApiClientLogin\execute(), ApiEditPage\execute(), ApiFeedContributions\execute(), ApiFeedWatchlist\execute(), ApiImageRotate\execute(), ApiOptions\execute(), ApiQueryAllMessages\execute(), ApiQueryTags\execute(), ApiFeedContributions\feedItemDesc(), MediaWiki\Pager\CategoryPager\formatRow(), MediaWiki\Pager\ActiveUsersPager\formatRow(), MediaWiki\Pager\MergeHistoryPager\formatRow(), MediaWiki\Pager\NewPagesPager\formatRow(), MediaWiki\Pager\ProtectedTitlesPager\formatRow(), MediaWiki\Pager\UsersPager\formatRow(), MediaWiki\Pager\AllMessagesTablePager\formatValue(), MediaWiki\Pager\ProtectedPagesPager\formatValue(), MediaWiki\Pager\UploadStashPager\formatValue(), MediaWiki\Pager\BlockListPager\formatValue(), ImageHistoryPseudoPager\getBody(), MediaWiki\HTMLForm\CodexHTMLForm\getButtons(), MediaWiki\HTMLForm\OOUIHTMLForm\getButtons(), EnhancedChangesList\getDiffHistLinks(), MediaWiki\Pager\HistoryPager\getEmptyBody(), MediaWiki\Pager\TablePager\getEmptyBody(), UploadForm\getExtensionsMessage(), MediaWiki\Pager\AllMessagesTablePager\getFieldNames(), MediaWiki\Pager\BlockListPager\getFieldNames(), MediaWiki\Pager\ImageListPager\getFieldNames(), MediaWiki\Pager\ProtectedPagesPager\getFieldNames(), MediaWiki\Pager\UploadStashPager\getFieldNames(), MediaWiki\Category\CategoryViewer\getHTML(), MediaWiki\HTMLForm\CodexHTMLForm\getLegend(), EditWatchlistNormalHTMLForm\getLegend(), EnhancedChangesList\getLineData(), EnhancedChangesList\getLogText(), MediaWiki\Pager\TablePager\getNavigationBar(), MediaWiki\Pager\UsersPager\getPageHeader(), UploadForm\getSourceSection(), MediaWiki\Pager\HistoryPager\getStartBody(), MediaWiki\Pager\AllMessagesTablePager\getStartBody(), SkinMustache\getTemplateData(), ImageHistoryList\getThumbForLine(), ImageHistoryList\imageHistoryLine(), ChangesList\insertLog(), FormatMetadata\makeFormattedData(), MediaWiki\Pager\ImageListPager\outputUserDoesNotExist(), MediaWiki\Pager\AllMessagesTablePager\reallyDoQuery(), EnhancedChangesList\recentChangesBlockGroup(), ImportReporter\reportNotice(), ImportReporter\reportPage(), Article\showDeletedRevisionHeader(), TraditionalImageGallery\toHTML(), and MediaWiki\Preferences\DefaultPreferencesFactory\validateSignature().

◆ setContext()


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