MediaWiki REL1_27
|
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 () | |
Get the Config object. | |
getLanguage () | |
Get the Language object. | |
getOutput () | |
Get the OutputPage object. | |
getRequest () | |
Get the WebRequest object. | |
getSkin () | |
Get the Skin object. | |
getStats () | |
Get the Stats object. | |
getTiming () | |
Get the timing object. | |
getTitle () | |
Get the Title object. | |
getUser () | |
Get the User object. | |
getWikiPage () | |
Get the WikiPage object. | |
hasTitle () | |
Check, if a Title object is set. | |
msg () | |
Helpful methods. | |
setConfig (Config $c) | |
Set the Config object. | |
setLanguage ( $l) | |
Set the Language object. | |
setOutput (OutputPage $o) | |
setRequest (WebRequest $r) | |
Set the WebRequest object. | |
setSkin (Skin $s) | |
Set the Skin object. | |
setTitle (Title $title=null) | |
Set the Title object. | |
setUser (User $u) | |
Set the User object. | |
setWikiPage (WikiPage $p) | |
Set the WikiPage object. | |
Static Public Member Functions | |
static | getMain () |
Static methods. | |
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 207 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 507 of file RequestContext.php.
References getRequest(), and getUser().
RequestContext::getConfig | ( | ) |
Get the Config object.
Implements IContextSource.
Definition at line 97 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 344 of file RequestContext.php.
References $code, $e, $lang, $request, $user, $wgContLang, getConfig(), User\getOption(), getRequest(), getUser(), WebRequest\getVal(), global, sanitizeLangCode(), and wfDebugLog().
|
static |
Static methods.
Get the RequestContext object associated with the main request
Definition at line 467 of file RequestContext.php.
References $instance.
Referenced by ApiMain\__construct(), CliInstaller\__construct(), Installer\__construct(), UserBlockedError\__construct(), MediaWiki\__construct(), LogFormatter\__construct(), MediaWiki\Session\PHPSessionHandler\__construct(), StubUserLang\_newObject(), BotPasswordTest\addDBData(), MediaWiki\Session\BotPasswordSessionProviderTest\addDBDataOnce(), ResourceLoaderModule\buildContent(), Linker\buildRollbackLink(), Preprocessor\cacheGetTree(), Preprocessor\cacheSetTree(), SpecialPageFactory\capturePath(), ApiStashEdit\checkCache(), Title\checkUserBlock(), LBFactory\commitAll(), User\comparePasswords(), User\crypt(), ApiTestCase\doApiRequest(), ApiTestCase\doLogin(), SiteStatsUpdate\doUpdateContextStats(), SpecialUserLogout\execute(), LoginSignupSpecialPage\execute(), Undelete\execute(), UpdateMediaWiki\execute(), WrapOldPasswords\execute(), DBConnectionError\fileCachedPage(), ResourceLoader\filter(), ChangesList\flag(), FeedUtils\formatDiffRow(), ChangeTags\formatSummaryRow(), File\generateAndSaveThumb(), File\generateBucketsIfNeeded(), Linker\generateRollback(), User\getBlockedStatus(), ActionTest\getContext(), Action\getContext(), ContextSource\getContext(), Article\getContext(), Profiler\getContext(), SpecialPage\getContext(), WatchedItemStore\getDefaultInstance(), MWTimestamp\getHumanTimestamp(), Language\getHumanTimestamp(), Message\getLanguage(), File\getLocalRefPath(), ApiDocumentationTest\getMain(), getMainAndWarn(), ApiContinuationManagerTest\getManager(), BotPassword\getPassword(), User\getPasswordFactory(), MediaWiki\Session\BotPasswordSessionProviderTest\getProvider(), MWTimestamp\getRelativeTimestamp(), User\getRights(), SpecialPageFactory\getUsablePages(), ApiMain\handleApiBeforeMainException(), EditPage\handleStatus(), importScopedSession(), JobQueue\incrStats(), HTMLButtonField\isBadIE(), WikitextContent\isCountable(), LBFactory\newChronologyProtector(), SpecialPageExecutor\newContext(), EmailNotification\notifyOnPageChange(), CategoryMembershipChangeJob\notifyUpdatesForRevision(), MessageCache\replace(), UserNotLoggedIn\report(), User\resetOptions(), ChangeTags\restrictedTagError(), AssembleUploadChunksJob\run(), PublishStashedFileJob\run(), JobRunner\run(), SpecialBotPasswords\save(), TestUser\setPasswordForUser(), EditPage\setPostEditCookie(), LoginSignupSpecialPage\setSessionUserForCurrentRequest(), UploadFromUrlTestSuite\setUp(), ParserTest\setupGlobals(), WebInstaller\setupLanguage(), MediaWikiTestCase\setUserLang(), ChangesList\showCharacterDifference(), LogEventsList\showLogExtract(), MediaWiki\Auth\ConfirmLinkSecondaryAuthenticationProviderTest\testBeginLinkAttempt(), ApiLoginTest\testBotPassword(), MediaWiki\Session\SessionManagerTest\testConstructor(), ApiResultTest\testDeprecatedContinuation(), ApiResultTest\testDeprecatedFunctions(), ApiDocumentationTest\testDocumentationExists(), ImageListPagerTest\testFormatValuesThrowException(), ActionTest\testGetActionName_whenCanNotUseWikiPage_defaultsToView(), RequestContextTest\testImportScopedSession(), BotPasswordTest\testLogin(), BotPasswordTest\testSave(), MediaWiki\Auth\AuthManagerTest\testSingleton(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProviderTest\testTestUserCanAuthenticate(), MediaWikiTest\testTryNormaliseRedirect(), WikiPage\triggerOpportunisticLinksUpdate(), EmailNotification\updateWatchlistTimestamp(), wfIncrStats(), 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 483 of file RequestContext.php.
References getMain(), and wfDebug().
Referenced by ImageGalleryBase\factory().
RequestContext::getOutput | ( | ) |
Get the OutputPage object.
Implements IContextSource.
Definition at line 267 of file RequestContext.php.
RequestContext::getRequest | ( | ) |
Get the WebRequest object.
Implements IContextSource.
Definition at line 121 of file RequestContext.php.
References $request, $wgCommandLineMode, global, and request.
Referenced by exportSession(), getLanguage(), getSkin(), and getUser().
RequestContext::getSkin | ( | ) |
Get the Skin object.
Implements IContextSource.
Definition at line 402 of file RequestContext.php.
References $factory, $skin, getConfig(), getRequest(), getUser(), Skin\normalizeKey(), ContextSource\setContext(), and skin().
RequestContext::getStats | ( | ) |
Get the Stats object.
Implements IContextSource.
Definition at line 142 of file RequestContext.php.
RequestContext::getTiming | ( | ) |
Get the timing object.
Implements IContextSource.
Definition at line 151 of file RequestContext.php.
References $timing.
RequestContext::getTitle | ( | ) |
Get the Title object.
Implements IContextSource.
Definition at line 176 of file RequestContext.php.
References $title, $wgTitle, global, title, wfDebugLog(), and wfGetAllCallers().
Referenced by canUseWikiPage(), and getWikiPage().
RequestContext::getUser | ( | ) |
Get the User object.
Implements IContextSource.
Definition at line 289 of file RequestContext.php.
References $user, getRequest(), and user.
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 243 of file RequestContext.php.
References $title, $wikipage, WikiPage\factory(), and getTitle().
RequestContext::hasTitle | ( | ) |
Check, if a Title object is set.
Definition at line 195 of file RequestContext.php.
References title.
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 539 of file RequestContext.php.
References $context, $name, $params, $request, $user, $value, $wgRequest, $wgUser, array(), as, User\getId(), getMain(), global, IP\isValid(), User\load(), WebRequest\setIP(), and use.
Referenced by AssembleUploadChunksJob\run(), PublishStashedFileJob\run(), and RequestContextTest\testImportScopedSession().
RequestContext::msg | ( | ) |
Helpful methods.
Get a Message object with context set Parameters are the same as wfMessage()
mixed | ... |
Implements IContextSource.
Definition at line 454 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 637 of file RequestContext.php.
References $context, $request, and $title.
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 493 of file RequestContext.php.
Referenced by LogFormatterTestCase\doTestLogFormatter(), ParserTest\setUp(), TitlePermissionTest\setUp(), UploadFromUrlTestSuite\setUp(), ParserTest\setupGlobals(), 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 303 of file RequestContext.php.
References $code, $wgLanguageCode, global, and wfDebug().
Referenced by ApiMain\__construct(), getLanguage(), DerivativeContext\setLanguage(), and setLanguage().
RequestContext::setConfig | ( | Config | $c | ) |
Set the Config object.
Config | $c |
Implements MutableContext.
Definition at line 88 of file RequestContext.php.
Referenced by ApiFormatPhpTest\testCrossDomainMangling().
RequestContext::setLanguage | ( | $l | ) |
Set the Language object.
MWException |
Implements MutableContext.
Definition at line 325 of file RequestContext.php.
References sanitizeLangCode().
RequestContext::setOutput | ( | OutputPage | $o | ) |
OutputPage | $o |
Implements MutableContext.
Definition at line 258 of file RequestContext.php.
References output().
RequestContext::setRequest | ( | WebRequest | $r | ) |
Set the WebRequest object.
WebRequest | $r |
Implements MutableContext.
Definition at line 112 of file RequestContext.php.
References request.
Referenced by SpecialRecentchangesTest\assertConditions(), ApiFormatTestBase\encodeData(), and ApiEditPage\execute().
RequestContext::setSkin | ( | Skin | $s | ) |
Set the Skin object.
Skin | $s |
Implements MutableContext.
Definition at line 392 of file RequestContext.php.
References $s, ContextSource\setContext(), and skin().
RequestContext::setTitle | ( | Title | $title = null | ) |
Set the Title object.
Title | $title |
Implements MutableContext.
Definition at line 165 of file RequestContext.php.
Referenced by PreferencesTest\__construct(), braceSubstitution(), RebuildFileCache\execute(), and setWikiPage().
RequestContext::setUser | ( | User | $u | ) |
Set the User object.
User | $u |
Implements MutableContext.
Definition at line 280 of file RequestContext.php.
References user.
Referenced by ApiParamInfo\execute(), and SpecialSearchTest\testProfileAndNamespaceLoading().
RequestContext::setWikiPage | ( | WikiPage | $p | ) |
Set the WikiPage object.
WikiPage | $p |
Implements MutableContext.
Definition at line 224 of file RequestContext.php.
References WikiPage\getTitle(), hasTitle(), and setTitle().
|
private |
Definition at line 76 of file RequestContext.php.
Referenced by getConfig().
|
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().
|
private |
Definition at line 36 of file RequestContext.php.
Referenced by getLanguage(), getRequest(), importScopedSession(), newExtraneousContext(), and ApiTestContext\newTestContext().
|
private |
Definition at line 66 of file RequestContext.php.
Referenced by getSkin().
|
private |
Definition at line 71 of file RequestContext.php.
Referenced by getTiming().
|
private |
Definition at line 41 of file RequestContext.php.
Referenced by canUseWikiPage(), getTitle(), getWikiPage(), newExtraneousContext(), and setTitle().
|
private |
Definition at line 56 of file RequestContext.php.
Referenced by getLanguage(), getUser(), importScopedSession(), and ApiTestContext\newTestContext().
|
private |
Definition at line 46 of file RequestContext.php.
Referenced by getWikiPage().