MediaWiki REL1_36
|
Group all the pieces relevant to the context of a request into one instance @newable. More...
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 () | |
getLanguage () | |
Get the Language object. | |
getOutput () | |
getRequest () | |
getSkin () | |
getStats () | |
getTiming () | |
getTitle () | |
getUser () | |
getWikiPage () | |
Get the WikiPage object. | |
hasTitle () | |
Check, if a Title object is set. | |
msg ( $key,... $params) | |
Get a Message object with context set Parameters are the same as wfMessage() | |
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. | |
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 an 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 sane. | |
Private Attributes | |
Authority | $authority |
Config | $config |
Language | $lang |
bool | $languageRecursion = false |
Boolean flag to guard against recursion in getLanguage. | |
OutputPage | $output |
WebRequest | $request |
Skin | $skin |
Timing | $timing |
Title | $title |
User | $user |
WikiPage | $wikipage |
Static Private Attributes | |
static RequestContext | $instance = null |
Group all the pieces relevant to the context of a request into one instance @newable.
Definition at line 40 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 213 of file RequestContext.php.
References $title, Title\canExist(), 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 520 of file RequestContext.php.
RequestContext::getAuthority | ( | ) |
Implements IContextSource.
Definition at line 313 of file RequestContext.php.
References getUser().
RequestContext::getConfig | ( | ) |
RequestContext::getLanguage | ( | ) |
Get the Language object.
Initialization of user or request objects can depend on this.
LogicException |
Implements IContextSource.
Definition at line 365 of file RequestContext.php.
References $lang, User\getOption(), and WebRequest\getRawVal().
|
static |
Get the RequestContext object associated with the main request.
Definition at line 480 of file RequestContext.php.
Referenced by MediaWiki\Block\AbstractBlock\appliesToRight(), MediaWiki\Block\AbstractBlock\appliesToUsertalk(), MediaWiki\Block\AbstractBlock\getReason(), and importScopedSession().
|
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 496 of file RequestContext.php.
References wfDebug().
RequestContext::getOutput | ( | ) |
RequestContext::getRequest | ( | ) |
Implements IContextSource.
Definition at line 134 of file RequestContext.php.
References $wgCommandLineMode.
Referenced by getUser().
RequestContext::getSkin | ( | ) |
RequestContext::getStats | ( | ) |
Implements IContextSource.
Definition at line 153 of file RequestContext.php.
RequestContext::getTiming | ( | ) |
RequestContext::getTitle | ( | ) |
RequestContext::getUser | ( | ) |
Implements IContextSource.
Definition at line 291 of file RequestContext.php.
References getRequest(), and User\newFromSession().
Referenced by getAuthority().
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 247 of file RequestContext.php.
References $title, and getTitle().
RequestContext::hasTitle | ( | ) |
Check, if a Title object is set.
Definition at line 201 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 552 of file RequestContext.php.
References $wgRequest, getMain(), User\newFromId(), and User\newFromName().
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 471 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 FauxRequest |
Definition at line 650 of file RequestContext.php.
References $title, and User\newFromName().
|
static |
Resets singleton returned by getMain().
Should be called only from unit tests.
Definition at line 506 of file RequestContext.php.
|
static |
Accepts a language code and ensures it's sane.
Outputs a cleaned up language code and replaces with $wgLanguageCode if not sane.
string | $code | Language code |
Definition at line 323 of file RequestContext.php.
References $wgLanguageCode.
RequestContext::setAuthority | ( | Authority | $authority | ) |
Authority | $authority |
Implements MutableContext.
Definition at line 299 of file RequestContext.php.
RequestContext::setConfig | ( | Config | $config | ) |
Config | $config |
Implements MutableContext.
Definition at line 107 of file RequestContext.php.
RequestContext::setLanguage | ( | $language | ) |
MWException |
Implements MutableContext.
Definition at line 346 of file RequestContext.php.
RequestContext::setOutput | ( | OutputPage | $output | ) |
OutputPage | $output |
Implements MutableContext.
Definition at line 262 of file RequestContext.php.
RequestContext::setRequest | ( | WebRequest | $request | ) |
WebRequest | $request |
Implements MutableContext.
Definition at line 127 of file RequestContext.php.
Referenced by ApiEditPage\execute().
RequestContext::setSkin | ( | Skin | $skin | ) |
Skin | $skin |
Implements MutableContext.
Definition at line 416 of file RequestContext.php.
References ContextSource\setContext().
RequestContext::setTitle | ( | Title | $title = null | ) |
Title | null | $title |
Implements MutableContext.
Definition at line 172 of file RequestContext.php.
References $title.
Referenced by Parser\braceSubstitution(), and setWikiPage().
RequestContext::setUser | ( | User | $user | ) |
User | $user |
Implements MutableContext.
Definition at line 280 of file RequestContext.php.
Referenced by ApiParamInfo\execute().
RequestContext::setWikiPage | ( | WikiPage | $wikiPage | ) |
WikiPage | $wikiPage |
Implements MutableContext.
Definition at line 228 of file RequestContext.php.
References WikiPage\getTitle(), hasTitle(), and setTitle().
|
private |
Definition at line 71 of file RequestContext.php.
|
private |
Definition at line 91 of file RequestContext.php.
|
staticprivate |
Definition at line 96 of file RequestContext.php.
|
private |
Definition at line 76 of file RequestContext.php.
|
private |
Boolean flag to guard against recursion in getLanguage.
Definition at line 102 of file RequestContext.php.
|
private |
Definition at line 61 of file RequestContext.php.
|
private |
Definition at line 46 of file RequestContext.php.
|
private |
Definition at line 81 of file RequestContext.php.
|
private |
Definition at line 86 of file RequestContext.php.
|
private |
Definition at line 51 of file RequestContext.php.
|
private |
Definition at line 66 of file RequestContext.php.
|
private |
Definition at line 56 of file RequestContext.php.