MediaWiki master
|
Group all the pieces relevant to the context of a request into one instance. More...
Inherits MediaWiki\Context\IContextSource, and MediaWiki\Context\MutableContext.
Public Member Functions | |
__clone () | |
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 () | |
getCsrfTokenSet () | |
Get a set of CSRF tokens to obtain and match specific tokens. | |
getLanguage () | |
Get the Language object. | |
getLanguageCode () | |
getOutput () | |
getRequest () | |
getSkin () | |
getSkinName () | |
Get the name of the skin. | |
getTiming () | |
getTitle () | |
getUser () | |
getWikiPage () | |
Get the WikiPage object. | |
hasTitle () | |
Check, if a Title object is set. | |
hasUser () | |
msg ( $key,... $params) | |
Get a Message object with context set Parameters are the same as wfMessage() | |
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) | |
![]() | |
setTitle (Title $title) | |
Static Public Member Functions | |
static | getMain () |
Get the RequestContext object associated with the main request. | |
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. | |
static | importScopedSession (array $params) |
Import a client IP address, HTTP headers, user ID, and session ID. | |
static | newExtraneousContext (Title $title, $request=[]) |
Create a new extraneous context. | |
static | resetMain () |
Resets singleton returned by getMain(). | |
static | sanitizeLangCode ( $code) |
Accepts a language code and ensures it's sensible. | |
Group all the pieces relevant to the context of a request into one instance.
Definition at line 68 of file RequestContext.php.
MediaWiki\Context\RequestContext::__clone | ( | ) |
Definition at line 799 of file RequestContext.php.
MediaWiki\Context\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 MediaWiki\Context\IContextSource.
Definition at line 239 of file RequestContext.php.
References MediaWiki\Title\Title\canExist(), and MediaWiki\Context\RequestContext\getTitle().
MediaWiki\Context\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 MediaWiki\Context\IContextSource.
Definition at line 648 of file RequestContext.php.
MediaWiki\Context\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 MediaWiki\Context\IContextSource.
Definition at line 307 of file RequestContext.php.
MediaWiki\Context\RequestContext::getAuthority | ( | ) |
Implements MediaWiki\Context\IContextSource.
Definition at line 400 of file RequestContext.php.
MediaWiki\Context\RequestContext::getConfig | ( | ) |
Implements MediaWiki\Context\IContextSource.
Definition at line 153 of file RequestContext.php.
References MediaWiki\MediaWikiServices\getInstance().
MediaWiki\Context\RequestContext::getCsrfTokenSet | ( | ) |
Get a set of CSRF tokens to obtain and match specific tokens.
Implements MediaWiki\Session\CsrfTokenSetProvider.
Definition at line 658 of file RequestContext.php.
MediaWiki\Context\RequestContext::getLanguage | ( | ) |
Get the Language object.
Initialization of user or request objects can depend on this.
LogicException |
Implements MediaWiki\Context\IContextSource.
Definition at line 454 of file RequestContext.php.
References MediaWiki\User\Options\UserOptionsLookup\getOption().
MediaWiki\Context\RequestContext::getLanguageCode | ( | ) |
Implements MediaWiki\Language\LocalizationContext.
Definition at line 508 of file RequestContext.php.
|
static |
Get the RequestContext object associated with the main request.
Definition at line 610 of file RequestContext.php.
Referenced by MediaWiki\Context\ContextSource\getContext().
|
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 624 of file RequestContext.php.
References wfDebug().
MediaWiki\Context\RequestContext::getOutput | ( | ) |
Implements MediaWiki\Context\IContextSource.
Definition at line 345 of file RequestContext.php.
MediaWiki\Context\RequestContext::getRequest | ( | ) |
Implements MediaWiki\Context\IContextSource.
Definition at line 168 of file RequestContext.php.
References MW_ENTRY_POINT.
MediaWiki\Context\RequestContext::getSkin | ( | ) |
Implements MediaWiki\Context\IContextSource.
Definition at line 575 of file RequestContext.php.
References Skin\normalizeKey().
MediaWiki\Context\RequestContext::getSkinName | ( | ) |
Get the name of the skin.
Definition at line 525 of file RequestContext.php.
MediaWiki\Context\RequestContext::getTiming | ( | ) |
Implements MediaWiki\Context\IContextSource.
Definition at line 186 of file RequestContext.php.
MediaWiki\Context\RequestContext::getTitle | ( | ) |
Implements MediaWiki\Context\IContextSource.
Definition at line 206 of file RequestContext.php.
References $wgTitle.
Referenced by MediaWiki\Context\RequestContext\canUseWikiPage(), and MediaWiki\Context\RequestContext\getWikiPage().
MediaWiki\Context\RequestContext::getUser | ( | ) |
Implements MediaWiki\Context\IContextSource.
Definition at line 364 of file RequestContext.php.
MediaWiki\Context\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.
Implements MediaWiki\Context\IContextSource.
Definition at line 274 of file RequestContext.php.
References MediaWiki\MediaWikiServices\getInstance(), and MediaWiki\Context\RequestContext\getTitle().
MediaWiki\Context\RequestContext::hasTitle | ( | ) |
Check, if a Title object is set.
Definition at line 227 of file RequestContext.php.
Referenced by MediaWiki\Context\RequestContext\setWikiPage().
MediaWiki\Context\RequestContext::hasUser | ( | ) |
Definition at line 379 of file RequestContext.php.
|
static |
Import a 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() |
Definition at line 681 of file RequestContext.php.
References $params, and $wgRequest.
MediaWiki\Context\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. @phpcs:ignore Generic.Files.LineLength |
MessageParam|MessageSpecifier|string|int|float|list<MessageParam|MessageSpecifier|string|int|float> | ...$params See Message::params() |
Implements MessageLocalizer.
Definition at line 603 of file RequestContext.php.
References $params, and 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 782 of file RequestContext.php.
|
static |
Resets singleton returned by getMain().
Should be called only from unit tests.
Definition at line 634 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 410 of file RequestContext.php.
References $wgLanguageCode.
MediaWiki\Context\RequestContext::setActionName | ( | string | $action | ) |
string | $action |
Implements MediaWiki\Context\MutableContext.
Definition at line 290 of file RequestContext.php.
MediaWiki\Context\RequestContext::setAuthority | ( | Authority | $authority | ) |
Authority | $authority |
Implements MediaWiki\Context\MutableContext.
Definition at line 386 of file RequestContext.php.
MediaWiki\Context\RequestContext::setConfig | ( | Config | $config | ) |
Implements MediaWiki\Context\MutableContext.
Definition at line 146 of file RequestContext.php.
MediaWiki\Context\RequestContext::setLanguage | ( | $language | ) |
Language | string | $language | Language instance or language code |
Implements MediaWiki\Context\MutableContext.
Definition at line 435 of file RequestContext.php.
MediaWiki\Context\RequestContext::setOutput | ( | OutputPage | $output | ) |
Implements MediaWiki\Context\MutableContext.
Definition at line 338 of file RequestContext.php.
MediaWiki\Context\RequestContext::setRequest | ( | WebRequest | $request | ) |
Implements MediaWiki\Context\MutableContext.
Definition at line 161 of file RequestContext.php.
Referenced by MediaWiki\Api\ApiEditPage\execute().
MediaWiki\Context\RequestContext::setSkin | ( | Skin | $skin | ) |
Implements MediaWiki\Context\MutableContext.
Definition at line 512 of file RequestContext.php.
References Skin\getSkinName(), and MediaWiki\Context\ContextSource\setContext().
MediaWiki\Context\RequestContext::setTitle | ( | ?Title | $title = null | ) |
Title | null | $title |
Definition at line 196 of file RequestContext.php.
Referenced by MediaWiki\Parser\Parser\braceSubstitution(), and MediaWiki\Context\RequestContext\setWikiPage().
MediaWiki\Context\RequestContext::setUser | ( | User | $user | ) |
Implements MediaWiki\Context\MutableContext.
Definition at line 351 of file RequestContext.php.
Referenced by MediaWiki\Api\ApiParamInfo\execute().
MediaWiki\Context\RequestContext::setWikiPage | ( | WikiPage | $wikiPage | ) |
WikiPage | $wikiPage |
Implements MediaWiki\Context\MutableContext.
Definition at line 254 of file RequestContext.php.
References WikiPage\getTitle(), MediaWiki\Context\RequestContext\hasTitle(), and MediaWiki\Context\RequestContext\setTitle().