MediaWiki REL1_37
ContextSource Class Reference

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

Inheritance diagram for ContextSource:
Collaboration diagram for 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.
 
 getAuthority ()
 
 getConfig ()
 
 getContext ()
 Get the base IContextSource object.
 
 getCsrfTokenSet ()
 Get a repository to obtain and match CSRF tokens.
 
 getLanguage ()
 
 getOutput ()
 
 getRequest ()
 
 getSkin ()
 
 getStats ()
 
 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)
 

Private Attributes

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

Definition at line 33 of file ContextSource.php.

Member Function Documentation

◆ canUseWikiPage()

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 IContextSource.

Reimplemented in DerivativeContext.

Definition at line 103 of file ContextSource.php.

References getContext().

◆ exportSession()

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 IContextSource.

Definition at line 209 of file ContextSource.php.

References getContext().

Referenced by ApiUpload\getChunkResult(), and ApiUpload\performUpload().

◆ getAuthority()

◆ getConfig()

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

Implements IContextSource.

Reimplemented in DerivativeContext.

Definition at line 72 of file ContextSource.php.

References getContext().

Referenced by ApiMain\__construct(), HTMLForm\__construct(), ImageGalleryBase\__construct(), ActiveUsersPager\__construct(), ApiQuery\__construct(), ApiBlock\__construct(), ApiEditPage\__construct(), ApiUpload\__construct(), ApiMove\__construct(), ApiDelete\__construct(), ApiRollback\__construct(), ApiWatch\__construct(), ApiProtect\__construct(), ApiUndelete\__construct(), ApiQueryQueryPage\__construct(), ImageListPager\__construct(), OutputPage\adaptCdnTTL(), OutputPage\addParserOutputMetadata(), UploadForm\addUploadJS(), ApiQuerySiteinfo\appendDbReplLagInfo(), ApiQuerySiteinfo\appendExtensions(), ApiQuerySiteinfo\appendFileExtensions(), ApiQuerySiteinfo\appendGeneralInfo(), ApiQuerySiteinfo\appendInterwikiMap(), ApiQuerySiteinfo\appendNamespaces(), ApiQuerySiteinfo\appendProtocols(), ApiQuerySiteinfo\appendRestrictions(), ApiQuerySiteinfo\appendRightsInfo(), ApiQuerySiteinfo\appendSubscribedHooks(), ApiQuerySiteinfo\appendUploadDialog(), ApiQuerySiteinfo\appendUserGroups(), SkinFallback\buildHelpfulInformationMessage(), OutputPage\checkLastModified(), ApiUpload\checkVerification(), DifferenceEngine\debug(), OutputPage\disallowUserJs(), ApiBlock\execute(), ApiEditPage\execute(), ApiEmailUser\execute(), ApiFeedContributions\execute(), ApiFeedRecentChanges\execute(), ApiFeedWatchlist\execute(), ApiFormatPhp\execute(), ApiLogin\execute(), ApiOpenSearch\execute(), ApiQueryAllUsers\execute(), ApiQueryAuthManagerInfo\execute(), ApiQueryBlocks\execute(), ApiQueryFileRepoInfo\execute(), ApiQueryLangLinks\execute(), ApiQueryLogEvents\execute(), ApiQueryUsers\execute(), ApiRemoveAuthenticationData\execute(), ApiRollback\execute(), ApiSetPageLanguage\execute(), ApiUndelete\execute(), ApiUpload\execute(), SkinFallback\findInstalledSkins(), OldChangesList\formatChangeLine(), HistoryPager\formatRow(), UsersPager\formatRow(), HTMLForm\getAction(), OutputPage\getAdvertisedFeedTypes(), ApiImport\getAllowedImportSources(), ApiQueryLogEvents\getAllowedLogActions(), 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(), HTMLForm\getButtons(), ApiQuerySiteinfo\getCacheMode(), OutputPage\getCacheVaryCookies(), ApiUpload\getChunkResult(), ApiQueryUserInfo\getCurrentUserInfo(), UploadForm\getDescriptionSection(), HistoryPager\getEndBody(), ApiResetPassword\getExamplesMessages(), ApiLogin\getExtendedDescription(), ApiSetPageLanguage\getExtendedDescription(), UploadForm\getExtensionsMessage(), OutputPage\getFeaturePolicyReportOnly(), ImageListPager\getFieldNames(), LogPager\getFilterParams(), ApiCSPReport\getFlags(), OutputPage\getFrameOptions(), HTMLForm\getHiddenFields(), CategoryViewer\getHTML(), HTMLButtonField\getInputHTML(), EnhancedChangesList\getLineData(), DifferenceEngine\getMarkPatrolledLinkInfo(), OutputPage\getOriginTrials(), ApiPageSet\getPageTableFields(), ActiveUsersPager\getQueryInfo(), LogPager\getQueryInfo(), NewFilesPager\getQueryInfo(), ApiQueryUserInfo\getRateLimits(), OutputPage\getReportTo(), ApiQueryBlocks\getRestrictionData(), BlockListPager\getRestrictionListHTML(), UploadForm\getSourceSection(), SkinFallback\getTemplateData(), ApiQueryInfo\getVisitingWatcherInfo(), ApiQueryInfo\getWatcherInfo(), ApiResetPassword\hasAnyRoutes(), Skin\initPage(), ApiFormatBase\initPrinter(), ApiLogin\isDeprecated(), ImageListPager\isFieldSortable(), LogPager\limitAction(), LogPager\limitTitle(), LogPager\limitType(), ApiQueryImageInfo\mergeThumbParams(), OutputPage\output(), Skin\preloadExistence(), ApiQueryUserContribs\prepareQuery(), ContribsPager\reallyDoQuery(), EnhancedChangesList\recentChangesBlockGroup(), EnhancedChangesList\recentChangesBlockLine(), ChangesList\recentChangesFlags(), ApiQueryInfo\requestExtraData(), ApiQueryAllImages\run(), ApiQueryAllPages\run(), ApiQueryCategoryMembers\run(), ApiQueryExtLinksUsage\run(), ApiQueryRecentChanges\run(), ApiQuerySearch\run(), ApiQueryAllDeletedRevisions\run(), ApiQueryAllRevisions\run(), ApiQueryBacklinksprop\run(), OutputPage\sendCacheControl(), HTMLForm\setDisplayFormat(), SkinTemplate\setupTemplate(), LogEventsList\showOptions(), LoginHelper\showReturnToPage(), and TraditionalImageGallery\toHTML().

◆ getContext()

ContextSource::getContext ( )

Get the base IContextSource object.

Since
1.18
Stability: stable
to override
Returns
IContextSource

Definition at line 47 of file ContextSource.php.

References $context, and wfDebug().

Referenced by ApiBase\__construct(), RevisionItem\__construct(), canUseWikiPage(), DerivativeContext\canUseWikiPage(), CategoryViewer\clearCategoryState(), SpecialUnblock\execute(), ApiChangeContentModel\execute(), ApiComparePages\execute(), ApiEmailUser\execute(), ApiExpandTemplates\execute(), ApiFeedContributions\execute(), ApiHelp\execute(), ApiQueryUsers\execute(), ApiRevisionDelete\execute(), ApiUserrights\execute(), ApiFeedContributions\feedItem(), ProtectedPagesPager\formatValue(), ApiUpload\getChunkResult(), getConfig(), DerivativeContext\getConfig(), ApiComparePages\getDiffRevision(), FormatMetadata\getExtendedMetadataFromHook(), ApiAMCreateAccount\getFinalDescription(), ApiClientLogin\getFinalDescription(), ApiLinkAccount\getFinalDescription(), EditWatchlistNormalHTMLForm\getLegend(), getOutput(), DerivativeContext\getOutput(), getRequest(), DerivativeContext\getRequest(), UploadForm\getSourceSection(), CategoryPager\getStartForm(), DerivativeContext\getTiming(), getTitle(), DerivativeContext\getTitle(), ApiUserrights\getUrUser(), getUser(), DerivativeContext\getUser(), getWikiPage(), DerivativeContext\getWikiPage(), ApiUpload\performUpload(), SpecialTags\processCreateTagForm(), SpecialTags\processTagForm(), MediaWiki\Preferences\DefaultPreferencesFactory\saveFormData(), SpecialComparePages\showDiff(), MediaWiki\Preferences\DefaultPreferencesFactory\submitForm(), and MediaWiki\Preferences\DefaultPreferencesFactory\validateSignature().

◆ getCsrfTokenSet()

ContextSource::getCsrfTokenSet ( )

Get a repository to obtain and match CSRF tokens.

Returns
CsrfTokenSet
Since
1.37

Implements MediaWiki\Session\CsrfTokenSetProvider.

Definition at line 219 of file ContextSource.php.

◆ getLanguage()

ContextSource::getLanguage ( )
Since
1.19
Stability: stable
to override
Returns
Language

Implements IContextSource.

Reimplemented in DerivativeContext.

Definition at line 153 of file ContextSource.php.

References getContext().

Referenced by ApiMain\__construct(), AllMessagesTablePager\__construct(), DifferenceEngine\addHeader(), ApiFeedWatchlist\execute(), ApiHelp\execute(), ApiParamInfo\execute(), ApiQueryAllMessages\execute(), ApiQueryLanguageinfo\execute(), FormatMetadata\fetchExtendedMetadata(), OldChangesList\formatChangeLine(), FormatMetadata\formatNum(), CategoryPager\formatRow(), ActiveUsersPager\formatRow(), NewFilesPager\formatRow(), UsersPager\formatRow(), AllMessagesTablePager\formatValue(), ProtectedPagesPager\formatValue(), BlockListPager\formatValue(), ChangesList\getArticleLink(), UploadForm\getExtensionsMessage(), CategoryViewer\getHTML(), IndexPager\getLimitLinks(), TablePager\getLimitSelectList(), AlphabeticPager\getNavigationBar(), ReverseChronologicalPager\getNavigationBar(), FormatMetadata\getPriorityLanguages(), ImageGalleryBase\getRenderLang(), BlockListPager\getRestrictionListHTML(), DifferenceEngine\getRevisionHeader(), DifferenceEngine\getSlotHeader(), UploadForm\getSourceSection(), ImageHistoryList\getThumbForLine(), HistoryPager\historyLine(), ImageHistoryList\imageHistoryLine(), ChangesList\insertDateHeader(), LogEventsList\logLine(), FormatMetadata\makeFormattedData(), EnhancedChangesList\recentChangesBlockGroup(), EnhancedChangesList\recentChangesLine(), HistoryPager\revLink(), and DifferenceEngine\showMissingRevision().

◆ getOutput()

◆ getRequest()

◆ getSkin()

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

Implements IContextSource.

Reimplemented in DerivativeContext.

Definition at line 162 of file ContextSource.php.

References getContext().

Referenced by OutputPage\output().

◆ getStats()

ContextSource::getStats ( )
Deprecated:
since 1.27 use a StatsdDataFactory from MediaWikiServices (preferably injected)
Since
1.25
Stability: stable
to override
Returns
IBufferingStatsdDataFactory

Implements IContextSource.

Reimplemented in DerivativeContext.

Definition at line 182 of file ContextSource.php.

◆ getTiming()

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

Implements IContextSource.

Reimplemented in DerivativeContext.

Definition at line 171 of file ContextSource.php.

References getContext().

◆ getTitle()

ContextSource::getTitle ( )
Since
1.18
Stability: stable
to override
Returns
Title|null

Implements IContextSource.

Reimplemented in DerivativeContext, DifferenceEngine, HTMLForm, ImageHistoryPseudoPager, AllMessagesTablePager, ImageListPager, and ProtectedTitlesPager.

Definition at line 90 of file ContextSource.php.

References getContext().

Referenced by TablePager\getNavigationBar(), and IndexPager\makeLink().

◆ getUser()

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

Implements IContextSource.

Reimplemented in DerivativeContext.

Definition at line 136 of file ContextSource.php.

References getContext().

Referenced by ImageHistoryPseudoPager\__construct(), IndexPager\__construct(), DifferenceEngine\addHeader(), OutputPage\checkLastModified(), ApiBlock\execute(), ApiChangeAuthenticationData\execute(), ApiCheckToken\execute(), ApiClearHasMsg\execute(), ApiCSPReport\execute(), ApiDelete\execute(), ApiEditPage\execute(), ApiEmailUser\execute(), ApiImport\execute(), ApiLinkAccount\execute(), ApiLogout\execute(), ApiManageTags\execute(), ApiMove\execute(), ApiPatrol\execute(), ApiProtect\execute(), ApiPurge\execute(), ApiQueryAuthManagerInfo\execute(), ApiQueryDeletedrevs\execute(), ApiQueryFilearchive\execute(), ApiQueryLogEvents\execute(), ApiQueryMyStashedFiles\execute(), ApiQueryStashImageInfo\execute(), ApiQueryTokens\execute(), ApiRemoveAuthenticationData\execute(), ApiResetPassword\execute(), ApiRevisionDelete\execute(), ApiRollback\execute(), ApiSetNotificationTimestamp\execute(), ApiSetPageLanguage\execute(), ApiStashEdit\execute(), ApiTag\execute(), ApiUnblock\execute(), ApiUndelete\execute(), ApiUpload\execute(), ApiUserrights\execute(), ApiValidatePassword\execute(), ApiWatch\execute(), ApiQueryWatchlist\extractOutputData(), ApiQueryLogEvents\extractRowInfo(), ApiQueryRecentChanges\extractRowInfo(), HistoryPager\formatRow(), UsersPager\formatRow(), ProtectedPagesPager\formatValue(), ApiQueryLogEvents\getCacheMode(), ApiUpload\getChunkResult(), ApiUpload\getContextResult(), ApiQueryUserInfo\getCurrentUserInfo(), Skin\getDefaultModules(), UploadForm\getDescriptionSection(), ApiComparePages\getDiffRevision(), HistoryPager\getEndBody(), HTMLForm\getHiddenFields(), ApiQueryUserInfo\getLatestContributionTime(), DifferenceEngine\getMarkPatrolledLinkInfo(), PreferencesFormOOUI\getModifiedUser(), UploadForm\getOptionsSection(), ApiParse\getPoolKey(), ApiQueryUserInfo\getRateLimits(), DifferenceEngine\getRevisionHeader(), LogEventsList\getShowHideLinks(), UploadForm\getSourceSection(), ImageHistoryList\getThumbForLine(), ApiOptions\getUserForUpdates(), ApiQueryInfo\getWatchedInfo(), ChangesList\getWatchlistExpiry(), HistoryPager\historyLine(), ImageHistoryList\imageHistoryLine(), ChangesList\insertDateHeader(), Skin\isResponsive(), LogPager\limitType(), ApiMove\movePage(), OutputPage\parserOptions(), ApiUpload\performStash(), ApiUpload\performUpload(), Skin\preloadExistence(), ApiQueryUserContribs\prepareQuery(), ApiTag\processIndividual(), ImportReporter\reportPage(), HistoryPager\revLink(), ApiQueryRecentChanges\run(), ApiQueryWatchlist\run(), ApiQueryAllDeletedRevisions\run(), ApiQueryDeletedRevisions\run(), ApiUpload\selectUploadModule(), SkinTemplate\setupTemplateContext(), ApiComparePages\setVals(), DifferenceEngine\showDiffPage(), OutputPage\showPermissionsErrorPage(), HTMLForm\tryAuthorizedSubmit(), RevDelList\updateLog(), and MediaWiki\Preferences\DefaultPreferencesFactory\validateSignature().

◆ getWikiPage()

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 IContextSource.

Reimplemented in DerivativeContext.

Definition at line 117 of file ContextSource.php.

References getContext().

Referenced by HistoryPager\curLink(), HistoryPager\getQueryInfo(), HistoryPager\historyLine(), and DifferenceEngine\renderNewRevision().

◆ msg()

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 DerivativeContext.

Definition at line 197 of file ContextSource.php.

References getContext().

Referenced by UploadForm\__construct(), DeletedContribsPager\__construct(), ContribsPager\__construct(), OutputPage\addHelpLink(), DifferenceEngine\addLocalisedTitleTooltipsCb(), ApiQuerySiteinfo\appendSkins(), ImageHistoryList\beginImageHistoryList(), SkinFallback\buildHelpfulInformationMessage(), ApiUpload\checkPermissions(), ImportReporter\close(), ApiFormatBase\closePrinter(), FormatMetadata\collapseContactInfo(), ApiFeedWatchlist\execute(), ApiOptions\execute(), ApiQueryTags\execute(), FormatMetadata\exifMsg(), ApiQueryRevisionsBase\extractAllSlotInfo(), FormatMetadata\formatCoords(), CategoryPager\formatRow(), ActiveUsersPager\formatRow(), UsersPager\formatRow(), AllMessagesTablePager\formatValue(), ProtectedPagesPager\formatValue(), BlockListPager\formatValue(), LogEventsList\getActionSelectorDesc(), HTMLForm\getButtons(), OOUIHTMLForm\getButtons(), VFormHTMLForm\getButtons(), PreferencesFormOOUI\getButtons(), DifferenceEngine\getDiff(), EnhancedChangesList\getDiffHistLinks(), HistoryPager\getEmptyBody(), TablePager\getEmptyBody(), UploadForm\getExtensionsMessage(), ApiFeedRecentChanges\getFeedObject(), AllMessagesTablePager\getFieldNames(), BlockListPager\getFieldNames(), ImageListPager\getFieldNames(), ProtectedPagesPager\getFieldNames(), CategoryViewer\getHTML(), HTMLForm\getLegend(), EditWatchlistNormalHTMLForm\getLegend(), TablePager\getLimitDropdown(), EnhancedChangesList\getLineData(), EnhancedChangesList\getLogText(), AlphabeticPager\getNavigationBar(), ReverseChronologicalPager\getNavigationBar(), TablePager\getNavigationBar(), UsersPager\getPageHeader(), BlockListPager\getRestrictionListHTML(), HistoryPager\getRevisionButton(), DifferenceEngine\getRevisionHeader(), UploadForm\getSourceSection(), HistoryPager\getStartBody(), AllMessagesTablePager\getStartBody(), HTMLForm\getSubmitText(), SkinMustache\getTemplateData(), ImageHistoryList\getThumbForLine(), ApiUpload\handleStashException(), HistoryPager\historyLine(), ImageHistoryList\imageHistoryLine(), ChangesList\insertLog(), FormatMetadata\langItem(), DifferenceEngine\localiseLineNumbersCb(), FormatMetadata\makeFormattedData(), IndexPager\makeLink(), DifferenceEngine\markPatrolledLink(), ChangesList\preCacheMessages(), AllMessagesTablePager\reallyDoQuery(), EnhancedChangesList\recentChangesBlockGroup(), ImportReporter\reportNotice(), ImportReporter\reportPage(), OutputPage\setPageTitle(), HTMLForm\setSubmitTextMsg(), HTMLForm\setWrapperLegendMsg(), Article\showDeletedRevisionHeader(), DifferenceEngine\showDiffPage(), OutputPage\showErrorPage(), DifferenceEngine\showMissingRevision(), OutputPage\showPermissionsErrorPage(), TraditionalImageGallery\toHTML(), MediaWiki\Preferences\DefaultPreferencesFactory\validateSignature(), and OutputPage\versionRequired().

◆ setContext()

Member Data Documentation

◆ $context


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