MediaWiki
1.34.0
|
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... | |
getConfig () | |
getLanguage () | |
Get the Language object. More... | |
getOutput () | |
getRequest () | |
getSkin () | |
getStats () | |
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... | |
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 sane. More... | |
Private Attributes | |
Config | $config |
Language | $lang |
bool | $languageRecursion = false |
Boolean flag to guard against recursion in getLanguage. More... | |
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.
Definition at line 33 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 198 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 471 of file RequestContext.php.
References MediaWiki\Session\SessionManager\getGlobalSession(), getRequest(), and getUser().
RequestContext::getConfig | ( | ) |
Implements IContextSource.
Definition at line 100 of file RequestContext.php.
References $config.
Referenced by getLanguage(), and getSkin().
RequestContext::getLanguage | ( | ) |
Get the Language object.
Initialization of user or request objects can depend on this.
Exception |
Implements IContextSource.
Definition at line 326 of file RequestContext.php.
References $lang, $request, $user, Language\factory(), getConfig(), User\getOption(), WebRequest\getRawVal(), getRequest(), getUser(), Hooks\run(), sanitizeLangCode(), and wfDebugLog().
|
static |
Get the RequestContext object associated with the main request.
Definition at line 431 of file RequestContext.php.
References $instance.
Referenced by UserBlockedError\__construct(), PermissionsError\__construct(), SpecialMute\__construct(), MediaWiki\__construct(), MediaWiki\Session\PHPSessionHandler\__construct(), Pingback\__construct(), LogFormatter\__construct(), MediaWiki\Session\SessionBackend\__construct(), ApiMain\__construct(), Installer\__construct(), StubUserLang\_newObject(), MediaWiki\Block\AbstractBlock\appliesToRight(), MediaWiki\Block\AbstractBlock\appliesToUsertalk(), SpecialBlock\blockLogFlags(), Linker\buildRollbackLink(), ChangeTags\buildTagFilterSelector(), Preprocessor\cacheGetTree(), Preprocessor\cacheSetTree(), MediaWiki\Extension\OATHAuth\Hook\TwoFactorIsEnabled\SetIsEnabled\callback(), MediaWiki\Extension\OATHAuth\Hook\GetUserPermissionsErrors\CheckExclusiveRights\callback(), MediaWiki\Special\SpecialPageFactory\capturePath(), MediaWiki\Permissions\PermissionManager\checkUserBlock(), TextSlotDiffRenderer\diff(), Undelete\execute(), RebuildFileCache\execute(), UpdateMediaWiki\execute(), LoginSignupSpecialPage\execute(), ChangesList\flag(), CaptchaPreAuthenticationProviderTest\flagSession(), FeedUtils\formatDiffRow(), ChangeTags\formatSummaryRow(), Linker\generateRollback(), MediaWiki\Auth\AuthManager\getAuthenticationRequestsInternal(), User\getBlockedStatus(), ContextSource\getContext(), Profiler\getContext(), Action\getContext(), SpecialPage\getContext(), Article\getContext(), HTMLFancyCaptchaFieldTest\getForm(), MediaWiki\Session\SessionManager\getGlobalSession(), MWTimestamp\getHumanTimestamp(), Language\getHumanTimestamp(), getMainAndWarn(), GadgetHooks\getPreferences(), MWTimestamp\getRelativeTimestamp(), WebRequest\getRequestId(), ParserOutput\getText(), MediaWiki\Special\SpecialPageFactory\getUsablePages(), ApiMain\handleApiBeforeMainException(), DeferredUpdates\handleUpdateQueue(), importScopedSession(), HTMLButtonField\isBadIE(), WikitextContent\isCountable(), Status\languageFromParam(), MediaWiki\Rest\EntryPoint\main(), User\newFatalPermissionDeniedStatus(), EmailNotification\notifyOnPageChange(), CategoryMembershipChangeJob\notifyUpdatesForRevision(), TitleBlacklistHooks\onDisplayBlacklistOverrideNotice(), SpecialUserLogout\onSubmit(), MediaWiki\Block\AbstractBlock\prevents(), WikiImporter\processTitle(), CategoryTree\renderNodeInfo(), UserNotLoggedIn\report(), User\resetOptions(), ChangeTags\restrictedTagError(), AssembleUploadChunksJob\run(), PublishStashedFileJob\run(), MediaWiki\Auth\AuthManager\setDefaultUserOptions(), LoginSignupSpecialPage\setSessionUserForCurrentRequest(), WebInstaller\setupLanguage(), SimpleCaptcha\shouldCheck(), MediaWiki\Block\DatabaseBlock\shouldTrackWithCookie(), ChangesList\showCharacterDifference(), LogEventsList\showLogExtract(), MediaWiki\Auth\AuthManager\singleton(), CaptchaTest\testCanSkipCaptchaIPWhitelisted(), CaptchaTest\testCanSkipCaptchaUserright(), CaptchaPreAuthenticationProviderTest\testGetAuthenticationRequests(), HTMLReCaptchaNoCaptchaFieldTest\testSubmit(), TitleBlacklistPreAuthenticationProvider\testUserForCreation(), MediaWiki\Auth\CheckBlocksSecondaryAuthenticationProvider\testUserForCreation(), Linker\tocList(), WikiPage\triggerOpportunisticLinksUpdate(), MWExceptionRenderer\useOutputPage(), ChangesList\userCan(), wfInstallerMain(), wfLogProfilingData(), 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 447 of file RequestContext.php.
References getMain(), and wfDebug().
Referenced by ImageGalleryBase\factory().
RequestContext::getOutput | ( | ) |
Implements IContextSource.
Definition at line 254 of file RequestContext.php.
References $output.
RequestContext::getRequest | ( | ) |
Implements IContextSource.
Definition at line 120 of file RequestContext.php.
References $request, and $wgCommandLineMode.
Referenced by exportSession(), getLanguage(), getSkin(), and getUser().
RequestContext::getSkin | ( | ) |
Implements IContextSource.
Definition at line 375 of file RequestContext.php.
References $skin, getConfig(), getRequest(), getUser(), Skin\normalizeKey(), and Hooks\run().
RequestContext::getStats | ( | ) |
Implements IContextSource.
Definition at line 139 of file RequestContext.php.
RequestContext::getTiming | ( | ) |
Implements IContextSource.
Definition at line 146 of file RequestContext.php.
References $timing.
RequestContext::getTitle | ( | ) |
Implements IContextSource.
Definition at line 167 of file RequestContext.php.
References $title, $wgTitle, wfDebugLog(), and wfGetAllCallers().
Referenced by canUseWikiPage(), and getWikiPage().
RequestContext::getUser | ( | ) |
Implements IContextSource.
Definition at line 274 of file RequestContext.php.
References $user, getRequest(), and User\newFromSession().
Referenced by exportSession(), getLanguage(), getSkin(), and MediaWiki\Rest\EntryPoint\main().
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 232 of file RequestContext.php.
References $title, $wikipage, WikiPage\factory(), and getTitle().
RequestContext::hasTitle | ( | ) |
Check, if a Title object is set.
Definition at line 186 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 503 of file RequestContext.php.
References $context, $request, $user, $wgRequest, User\getId(), getMain(), IP\isValid(), User\load(), User\newFromId(), User\newFromName(), WebRequest\setIP(), and MediaWiki\Session\SessionManager\singleton().
Referenced by AssembleUploadChunksJob\run(), PublishStashedFileJob\run(), and ReplaceTextJob\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 422 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 601 of file RequestContext.php.
References $context, $request, $title, and User\newFromName().
Referenced by LogPage\addEntry(), ManualLogEntry\getRecentChange(), MovePage\moveToInternal(), SpecialChangeContentModel\onSubmit(), and LocalFile\recordUpload2().
|
static |
Resets singleton returned by getMain().
Should be called only from unit tests.
Definition at line 457 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 288 of file RequestContext.php.
References $wgLanguageCode, and Language\isValidCode().
Referenced by ApiMain\__construct(), getLanguage(), DerivativeContext\setLanguage(), and setLanguage().
RequestContext::setConfig | ( | Config | $config | ) |
Config | $config |
Implements MutableContext.
Definition at line 93 of file RequestContext.php.
References $config.
RequestContext::setLanguage | ( | $language | ) |
MWException |
Implements MutableContext.
Definition at line 307 of file RequestContext.php.
References Language\factory(), and sanitizeLangCode().
RequestContext::setOutput | ( | OutputPage | $output | ) |
OutputPage | $output |
Implements MutableContext.
Definition at line 247 of file RequestContext.php.
References $output.
RequestContext::setRequest | ( | WebRequest | $request | ) |
WebRequest | $request |
Implements MutableContext.
Definition at line 113 of file RequestContext.php.
References $request.
Referenced by ApiEditPage\execute().
RequestContext::setSkin | ( | Skin | $skin | ) |
Skin | $skin |
Implements MutableContext.
Definition at line 367 of file RequestContext.php.
References $skin, and ContextSource\setContext().
RequestContext::setTitle | ( | Title | $title = null | ) |
Title | null | $title |
Implements MutableContext.
Definition at line 158 of file RequestContext.php.
References $title.
Referenced by MediaWiki\Rest\EntryPoint\main(), and setWikiPage().
RequestContext::setUser | ( | User | $user | ) |
User | $user |
Implements MutableContext.
Definition at line 265 of file RequestContext.php.
References $user.
Referenced by ApiParamInfo\execute().
RequestContext::setWikiPage | ( | WikiPage | $wikiPage | ) |
WikiPage | $wikiPage |
Implements MutableContext.
Definition at line 213 of file RequestContext.php.
References WikiPage\getTitle(), hasTitle(), and setTitle().
|
private |
Definition at line 77 of file RequestContext.php.
Referenced by getConfig(), and setConfig().
|
staticprivate |
Definition at line 82 of file RequestContext.php.
Referenced by getMain().
|
private |
Definition at line 62 of file RequestContext.php.
Referenced by getLanguage().
|
private |
Boolean flag to guard against recursion in getLanguage.
Definition at line 88 of file RequestContext.php.
|
private |
Definition at line 52 of file RequestContext.php.
Referenced by getOutput(), and setOutput().
|
private |
Definition at line 37 of file RequestContext.php.
Referenced by getLanguage(), getRequest(), importScopedSession(), newExtraneousContext(), and setRequest().
|
private |
Definition at line 67 of file RequestContext.php.
|
private |
Definition at line 72 of file RequestContext.php.
Referenced by getTiming().
|
private |
Definition at line 42 of file RequestContext.php.
Referenced by canUseWikiPage(), getTitle(), getWikiPage(), newExtraneousContext(), and setTitle().
|
private |
Definition at line 57 of file RequestContext.php.
Referenced by getLanguage(), getUser(), importScopedSession(), and setUser().
|
private |
Definition at line 47 of file RequestContext.php.
Referenced by getWikiPage().