MediaWiki
master
|
Group all the pieces relevant to the context of a request into one instance. More...
Public Member Functions | |
canUseWikiPage () | |
Check whether a WikiPage object can be get with getWikiPage(). More... | |
exportSession () | |
Export the resolved user IP, HTTP headers, user ID, and session ID. More... | |
getActionName () | |
Get the action name for the current web request. More... | |
getAuthority () | |
getConfig () | |
getCsrfTokenSet () | |
Get a set of CSRF tokens to obtain and match specific tokens. More... | |
getLanguage () | |
Get the Language object. More... | |
getOutput () | |
getRequest () | |
getSkin () | |
getTiming () | |
getTitle () | |
getUser () | |
getWikiPage () | |
Get the WikiPage object. More... | |
hasTitle () | |
Check, if a Title object is set. More... | |
msg ( $key,... $params) | |
Get a Message object with context set Parameters are the same as wfMessage() More... | |
setActionName (string $action) | |
setAuthority (Authority $authority) | |
setConfig (Config $config) | |
setLanguage ( $language) | |
setOutput (OutputPage $output) | |
setRequest (WebRequest $request) | |
setSkin (Skin $skin) | |
setTitle (Title $title=null) | |
setUser (User $user) | |
setWikiPage (WikiPage $wikiPage) | |
Static Public Member Functions | |
static | getMain () |
Get the RequestContext object associated with the main request. More... | |
static | getMainAndWarn ( $func=__METHOD__) |
Get the RequestContext object associated with the main request and gives a warning to the log, to find places, where a context maybe is missing. More... | |
static | importScopedSession (array $params) |
Import an client IP address, HTTP headers, user ID, and session ID. More... | |
static | newExtraneousContext (Title $title, $request=[]) |
Create a new extraneous context. More... | |
static | resetMain () |
Resets singleton returned by getMain(). More... | |
static | sanitizeLangCode ( $code) |
Accepts a language code and ensures it's sensible. More... | |
Group all the pieces relevant to the context of a request into one instance.
Definition at line 44 of file RequestContext.php.
RequestContext::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.
Implements IContextSource.
Definition at line 210 of file RequestContext.php.
References $title, and getTitle().
RequestContext::exportSession | ( | ) |
Export the resolved user IP, HTTP headers, user ID, and session ID.
The result will be reasonably sized to allow for serialization.
Implements IContextSource.
Definition at line 583 of file RequestContext.php.
References MediaWiki\Session\SessionManager\getGlobalSession(), MediaWiki\Rest\Handler\getRequest(), and getUser().
RequestContext::getActionName | ( | ) |
Get the action name for the current web request.
This generally returns "view" if the current request or process is not for a skinned index.php web request (e.g. load.php, thumb.php, job runner, CLI, API).
Implements IContextSource.
Definition at line 279 of file RequestContext.php.
RequestContext::getAuthority | ( | ) |
Implements IContextSource.
Definition at line 370 of file RequestContext.php.
RequestContext::getConfig | ( | ) |
RequestContext::getCsrfTokenSet | ( | ) |
Get a set of CSRF tokens to obtain and match specific tokens.
Implements MediaWiki\Session\CsrfTokenSetProvider.
Definition at line 593 of file RequestContext.php.
RequestContext::getLanguage | ( | ) |
Get the Language object.
Initialization of user or request objects can depend on this.
LogicException |
Implements IContextSource.
Definition at line 425 of file RequestContext.php.
References MediaWiki\Rest\Handler\getRequest(), and getUser().
|
static |
Get the RequestContext object associated with the main request.
Definition at line 545 of file RequestContext.php.
Referenced by ApiMain\__construct(), HTMLTimezoneField\__construct(), PermissionsError\__construct(), CliInstaller\__construct(), UserBlockedError\__construct(), UploadStash\__construct(), MediaWiki\__construct(), LogFormatter\__construct(), MediaWiki\StubObject\StubUserLang\_newObject(), MediaWiki\Linker\Linker\buildRollbackLink(), ChangeTags\buildTagFilterSelector(), MediaWiki\SpecialPage\SpecialPageFactory\capturePath(), UploadBase\checkWarnings(), Parser\cleanSig(), Language\dateFormat(), TextSlotDiffRenderer\diff(), DeferredUpdates\doUpdates(), RebuildFileCache\execute(), UpdateMediaWiki\execute(), FileRepo\findFiles(), LocalRepo\findFiles(), WikiImporter\finishImportPage(), ChangesList\flag(), MediaWiki\Feed\FeedUtils\formatDiffRow2(), ChangeTags\formatSummaryRow(), MediaWiki\Linker\Linker\generateRollback(), MediaWiki\Rest\Handler\ActionModuleBasedHandler\getApiMain(), ContextSource\getContext(), Article\getContext(), Profiler\getContext(), SpecialPage\getContext(), LocalFile\getDescriptionText(), Parser\getFlatSectionInfo(), GenderCache\getGenderOf(), UserGroupMembership\getGroupMemberName(), UserGroupMembership\getGroupName(), Language\getHumanTimestamp(), Message\getLanguage(), LanguageConverter\getPreferredVariant(), MediaWiki\Block\AbstractBlock\getReason(), MWTimestamp\getRelativeTimestamp(), User\getRequest(), ParserOutput\getText(), MediaWiki\SpecialPage\SpecialPageFactory\getUsablePages(), ApiMain\handleApiBeforeMainException(), ImportableOldRevisionImporter\import(), importScopedSession(), WikitextContent\isCountable(), UploadFromUrl\isValidRequest(), MediaWiki\Rest\EntryPoint\main(), User\newFatalPermissionDeniedStatus(), UserNotLoggedIn\report(), Installer\resetMediaWikiServices(), ChangeTags\restrictedTagError(), MediaWiki\Linker\Linker\revComment(), MediaWiki\Linker\Linker\revUserLink(), MediaWiki\Linker\Linker\revUserTools(), AssembleUploadChunksJob\run(), PublishStashedFileJob\run(), LoginSignupSpecialPage\setSessionUserForCurrentRequest(), WebInstaller\setupLanguage(), ChangesList\showCharacterDifference(), LogEventsList\showLogExtract(), MediaWiki\Auth\CheckBlocksSecondaryAuthenticationProvider\testUserForCreation(), MediaWiki\Linker\Linker\tocList(), LocalFile\upload(), Language\userAdjust(), ChangesList\userCan(), MediaWiki\Linker\Linker\userToolLinks(), ContentHandler\validateSave(), wfApiMain(), wfImageAuthMain(), wfInstallerMain(), and wfStreamThumb().
|
static |
Get the RequestContext object associated with the main request and gives a warning to the log, to find places, where a context maybe is missing.
string | $func |
Definition at line 559 of file RequestContext.php.
References wfDebug().
Referenced by ImageGalleryBase\factory().
RequestContext::getOutput | ( | ) |
RequestContext::getRequest | ( | ) |
Implements IContextSource.
Definition at line 141 of file RequestContext.php.
References $wgCommandLineMode.
RequestContext::getSkin | ( | ) |
Implements IContextSource.
Definition at line 486 of file RequestContext.php.
References Skin\normalizeKey(), and Hooks\runner().
RequestContext::getTiming | ( | ) |
RequestContext::getTitle | ( | ) |
Implements IContextSource.
Definition at line 178 of file RequestContext.php.
References $wgTitle.
Referenced by canUseWikiPage(), and getWikiPage().
RequestContext::getUser | ( | ) |
Implements IContextSource.
Definition at line 340 of file RequestContext.php.
References MediaWiki\Rest\Handler\getRequest(), and User\newFromSession().
RequestContext::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.
MWException |
Implements IContextSource.
Definition at line 246 of file RequestContext.php.
References $title, and getTitle().
RequestContext::hasTitle | ( | ) |
Check, if a Title object is set.
Definition at line 198 of file RequestContext.php.
Referenced by setWikiPage().
|
static |
Import an client IP address, HTTP headers, user ID, and session ID.
This sets the current session, $wgUser, and $wgRequest from $params. Once the return value falls out of scope, the old context is restored. This method should only be called in contexts where there is no session ID or end user receiving the response (CLI or HTTP job runners). This is partly enforced, and is done so to avoid leaking cookies if certain error conditions arise.
This is useful when background scripts inherit context when acting on behalf of a user. In general the 'sessionId' parameter should be set to an empty string unless session importing is truly needed. This feature is somewhat deprecated.
array | $params | Result of RequestContext::exportSession() |
MWException |
Definition at line 617 of file RequestContext.php.
References $wgRequest, getMain(), User\newFromId(), User\newFromName(), and MediaWiki\Session\SessionManager\singleton().
Referenced by AssembleUploadChunksJob\run(), and PublishStashedFileJob\run().
RequestContext::msg | ( | $key, | |
$params | |||
) |
Get a Message object with context set Parameters are the same as wfMessage()
string | string[] | MessageSpecifier | $key | Message key, or array of keys, or a MessageSpecifier. |
mixed | ...$params |
Implements MessageLocalizer.
Definition at line 536 of file RequestContext.php.
References wfMessage().
|
static |
Create a new extraneous context.
The context is filled with information external to the current session.
Title | $title | Title to use for the extraneous request |
WebRequest | array | $request | A WebRequest or data to use for a MediaWiki\Request\FauxRequest |
Definition at line 715 of file RequestContext.php.
References $title, and User\newFromName().
Referenced by LogPage\addEntry(), ContentModelChange\doContentModelChange(), and ManualLogEntry\getRecentChange().
|
static |
Resets singleton returned by getMain().
Should be called only from unit tests.
Definition at line 569 of file RequestContext.php.
|
static |
Accepts a language code and ensures it's sensible.
Outputs a cleaned up language code and replaces with $wgLanguageCode if not sensible.
?string | $code Language code |
Definition at line 380 of file RequestContext.php.
References $wgLanguageCode.
Referenced by ApiMain\__construct(), and DerivativeContext\setLanguage().
RequestContext::setActionName | ( | string | $action | ) |
string | $action |
Implements MutableContext.
Definition at line 262 of file RequestContext.php.
RequestContext::setAuthority | ( | Authority | $authority | ) |
Authority | $authority |
Implements MutableContext.
Definition at line 358 of file RequestContext.php.
RequestContext::setConfig | ( | Config | $config | ) |
Config | $config |
Implements MutableContext.
Definition at line 116 of file RequestContext.php.
RequestContext::setLanguage | ( | $language | ) |
MWException |
Implements MutableContext.
Definition at line 406 of file RequestContext.php.
RequestContext::setOutput | ( | OutputPage | $output | ) |
OutputPage | $output |
Implements MutableContext.
Definition at line 313 of file RequestContext.php.
RequestContext::setRequest | ( | WebRequest | $request | ) |
WebRequest | $request |
Implements MutableContext.
Definition at line 134 of file RequestContext.php.
Referenced by ApiEditPage\execute().
RequestContext::setSkin | ( | Skin | $skin | ) |
Skin | $skin |
Implements MutableContext.
Definition at line 478 of file RequestContext.php.
References ContextSource\setContext().
RequestContext::setTitle | ( | Title | $title = null | ) |
Title | null | $title |
Implements MutableContext.
Definition at line 168 of file RequestContext.php.
References $title.
Referenced by Parser\braceSubstitution(), and setWikiPage().
RequestContext::setUser | ( | User | $user | ) |
User | $user |
Implements MutableContext.
Definition at line 329 of file RequestContext.php.
Referenced by ApiParamInfo\execute().
RequestContext::setWikiPage | ( | WikiPage | $wikiPage | ) |
WikiPage | $wikiPage |
Implements MutableContext.
Definition at line 225 of file RequestContext.php.
References WikiPage\getTitle(), hasTitle(), and setTitle().