MediaWiki REL1_31
|
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(). | |
exportSession () | |
Export the resolved user IP, HTTP headers, user ID, and session ID. | |
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) | |
Get a Message object with context set Parameters are the same as wfMessage() | |
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 | |
Config | $config |
Language | $lang |
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 32 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 191 of file RequestContext.php.
References 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 474 of file RequestContext.php.
References getRequest(), and getUser().
RequestContext::getConfig | ( | ) |
Implements IContextSource.
Definition at line 93 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 317 of file RequestContext.php.
References $code, $e, $lang, $request, $wgContLang, getConfig(), getRequest(), getUser(), WebRequest\getVal(), sanitizeLangCode(), and wfDebugLog().
|
static |
Get the RequestContext object associated with the main request.
Definition at line 434 of file RequestContext.php.
References $instance.
Referenced by ApiMain\__construct(), PermissionsError\__construct(), CliInstaller\__construct(), Installer\__construct(), UserBlockedError\__construct(), Pingback\__construct(), MediaWiki\__construct(), LogFormatter\__construct(), MediaWiki\Session\PHPSessionHandler\__construct(), StubUserLang\_newObject(), BotPasswordTest\addDBData(), ApiComparePagesTest\addDBDataOnce(), MediaWiki\Session\BotPasswordSessionProviderTest\addDBDataOnce(), Linker\buildRollbackLink(), ChangeTags\buildTagFilterSelector(), Preprocessor\cacheGetTree(), Preprocessor\cacheSetTree(), SpecialPageFactory\capturePath(), Title\checkUserBlock(), TitleBlacklistHooks\displayBlacklistOverrideNotice(), ApiTestCase\doApiRequest(), ApiTestCase\doLogin(), SpecialUserLogout\execute(), LoginSignupSpecialPage\execute(), RebuildFileCache\execute(), Undelete\execute(), UpdateMediaWiki\execute(), WrapOldPasswords\execute(), DeferredUpdates\execute(), ChangesList\flag(), CaptchaPreAuthenticationProviderTest\flagSession(), FeedUtils\formatDiffRow(), ChangeTags\formatSummaryRow(), Linker\formatTemplates(), Linker\generateRollback(), User\getBlockedStatus(), User\getBlockFromCookieValue(), ActionTest\getContext(), Action\getContext(), ContextSource\getContext(), Article\getContext(), Profiler\getContext(), SpecialPage\getContext(), Block\getCookieValue(), HTMLFancyCaptchaFieldTest\getForm(), MWTimestamp\getHumanTimestamp(), Language\getHumanTimestamp(), Block\getIdFromCookieValue(), Message\getLanguage(), ApiStructureTest\getMain(), getMainAndWarn(), ApiContinuationManagerTest\getManager(), BotPassword\getPassword(), MediaWiki\Session\BotPasswordSessionProviderTest\getProvider(), MWTimestamp\getRelativeTimestamp(), User\getRights(), SpecialPageFactory\getUsablePages(), ApiMain\handleApiBeforeMainException(), importScopedSession(), HTMLButtonField\isBadIE(), WikitextContent\isCountable(), User\loadFromSession(), PageDataRequestHandlerTest\makeOutputPage(), SpecialPageExecutor\newContext(), User\newFatalPermissionDeniedStatus(), EmailNotification\notifyOnPageChange(), CategoryMembershipChangeJob\notifyUpdatesForRevision(), ParserTestRunner\perTestSetup(), CategoryTree\renderNodeInfo(), MessageCache\replace(), UserNotLoggedIn\report(), User\resetOptions(), ResourceLoader\respond(), ChangeTags\restrictedTagError(), ApiTestCase\revisionDelete(), AssembleUploadChunksJob\run(), PublishStashedFileJob\run(), ParserTestRunner\runTest(), SpecialBotPasswords\save(), TestUser\setPasswordForUser(), LoginSignupSpecialPage\setSessionUserForCurrentRequest(), LogFormatterTest\setUp(), UploadFromUrlTestSuite\setUp(), WebInstaller\setupLanguage(), MediaWikiTestCase\setUserLang(), SimpleCaptcha\shouldCheck(), ChangesList\showCharacterDifference(), FileDeleteForm\showForm(), LogEventsList\showLogExtract(), MediaWiki\Auth\ConfirmLinkSecondaryAuthenticationProviderTest\testBeginLinkAttempt(), ApiLoginTest\testBotPassword(), MediaWiki\Session\SessionManagerTest\testConstructor(), ApiStructureTest\testDocumentationExists(), HTMLRestrictionsFieldTest\testForm(), ImageListPagerTest\testFormatValuesThrowException(), ActionTest\testGetActionName_whenCanNotUseWikiPage_defaultsToView(), CaptchaPreAuthenticationProviderTest\testGetAuthenticationRequests(), RequestContextTest\testImportScopedSession(), BotPasswordTest\testLogin(), BotPasswordTest\testSave(), MediaWiki\Auth\AuthManagerTest\testSingleton(), UserTest\testSoftBlockRanges(), HTMLReCaptchaNoCaptchaFieldTest\testSubmit(), HTMLSubmittedValueFieldTest\testSubmit(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProviderTest\testTestUserCanAuthenticate(), MediaWikiTest\testTryNormaliseRedirect(), ApiEditPageTest\testUndoAfterToHiddenRev(), TitleBlacklistPreAuthenticationProvider\testUserForCreation(), MediaWiki\Auth\CheckBlocksSecondaryAuthenticationProvider\testUserForCreation(), WikiPage\triggerOpportunisticLinksUpdate(), EmailNotification\updateWatchlistTimestamp(), MWExceptionRenderer\useOutputPage(), 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 450 of file RequestContext.php.
References getMain(), and wfDebug().
Referenced by ImageGalleryBase\factory().
RequestContext::getOutput | ( | ) |
RequestContext::getRequest | ( | ) |
Implements IContextSource.
Definition at line 113 of file RequestContext.php.
References $request, and $wgCommandLineMode.
Referenced by exportSession(), getLanguage(), getSkin(), and getUser().
RequestContext::getSkin | ( | ) |
Implements IContextSource.
Definition at line 371 of file RequestContext.php.
References $skin, getConfig(), getRequest(), getUser(), and skin().
RequestContext::getStats | ( | ) |
Implements IContextSource.
Definition at line 132 of file RequestContext.php.
RequestContext::getTiming | ( | ) |
Implements IContextSource.
Definition at line 139 of file RequestContext.php.
References $timing.
RequestContext::getTitle | ( | ) |
Implements IContextSource.
Definition at line 160 of file RequestContext.php.
References $title, $wgTitle, wfDebugLog(), and wfGetAllCallers().
Referenced by canUseWikiPage(), and getWikiPage().
RequestContext::getUser | ( | ) |
Implements IContextSource.
Definition at line 265 of file RequestContext.php.
References $user, getRequest(), and User\newFromSession().
Referenced by exportSession(), getLanguage(), and getSkin().
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 225 of file RequestContext.php.
References $wikipage, and getTitle().
RequestContext::hasTitle | ( | ) |
Check, if a Title object is set.
Definition at line 179 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 506 of file RequestContext.php.
References $context, $params, $request, $user, $value, $wgRequest, $wgUser, getMain(), User\newFromId(), User\newFromName(), and WebRequest\setIP().
Referenced by ReplaceTextJob\run(), AssembleUploadChunksJob\run(), PublishStashedFileJob\run(), and RequestContextTest\testImportScopedSession().
RequestContext::msg | ( | $key | ) |
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 | $args,... |
Implements MessageLocalizer.
Definition at line 423 of file RequestContext.php.
References $args.
|
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 604 of file RequestContext.php.
References $context, $request, and User\newFromName().
Referenced by LogPage\addEntry(), ManualLogEntry\getRecentChange(), MovePage\moveToInternal(), SpecialChangeContentModel\onSubmit(), LocalFile\recordUpload2(), and RecentChangeTest\setUp().
|
static |
Resets singleton returned by getMain().
Should be called only from unit tests.
Definition at line 460 of file RequestContext.php.
Referenced by MediaWikiTestCase\doLightweightServiceReset(), LogFormatterTestCase\doTestLogFormatter(), TitlePermissionTest\setUp(), UploadFromUrlTestSuite\setUp(), and MediaWikiTestCase\tearDown().
|
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 279 of file RequestContext.php.
References $code, and $wgLanguageCode.
Referenced by ApiMain\__construct(), getLanguage(), DerivativeContext\setLanguage(), and setLanguage().
RequestContext::setConfig | ( | Config | $config | ) |
Config | $config |
Implements MutableContext.
Definition at line 86 of file RequestContext.php.
References $config.
RequestContext::setLanguage | ( | $language | ) |
MWException |
Implements MutableContext.
Definition at line 298 of file RequestContext.php.
References sanitizeLangCode().
RequestContext::setOutput | ( | OutputPage | $output | ) |
OutputPage | $output |
Implements MutableContext.
Definition at line 240 of file RequestContext.php.
RequestContext::setRequest | ( | WebRequest | $request | ) |
WebRequest | $request |
Implements MutableContext.
Definition at line 106 of file RequestContext.php.
References $request.
Referenced by ApiEditPage\execute().
RequestContext::setSkin | ( | Skin | $skin | ) |
RequestContext::setTitle | ( | Title | $title = null | ) |
Title | null | $title |
Implements MutableContext.
Definition at line 151 of file RequestContext.php.
References $title.
Referenced by PreferencesTest\__construct(), and setWikiPage().
RequestContext::setUser | ( | User | $user | ) |
User | $user |
Implements MutableContext.
Definition at line 258 of file RequestContext.php.
References $user.
Referenced by ApiParamInfo\execute().
RequestContext::setWikiPage | ( | WikiPage | $wikiPage | ) |
WikiPage | $wikiPage |
Implements MutableContext.
Definition at line 206 of file RequestContext.php.
References hasTitle(), and setTitle().
|
private |
Definition at line 76 of file RequestContext.php.
Referenced by getConfig(), and setConfig().
|
staticprivate |
Definition at line 81 of file RequestContext.php.
Referenced by getMain().
|
private |
Definition at line 61 of file RequestContext.php.
Referenced by getLanguage().
|
private |
Definition at line 51 of file RequestContext.php.
Referenced by getOutput(), and setOutput().
|
private |
Definition at line 36 of file RequestContext.php.
Referenced by getLanguage(), getRequest(), importScopedSession(), newExtraneousContext(), ApiTestContext\newTestContext(), and setRequest().
|
private |
Definition at line 66 of file RequestContext.php.
|
private |
Definition at line 71 of file RequestContext.php.
Referenced by getTiming().
|
private |
Definition at line 41 of file RequestContext.php.
Referenced by getTitle(), and setTitle().
|
private |
Definition at line 56 of file RequestContext.php.
Referenced by getUser(), importScopedSession(), and setUser().
|
private |
Definition at line 46 of file RequestContext.php.
Referenced by getWikiPage().