27use Wikimedia\ScopedCallback;
94 if ( $this->config ===
null ) {
97 $this->config = MediaWikiServices::getInstance()->getMainConfig();
114 if ( $this->request ===
null ) {
133 return MediaWikiServices::getInstance()->getStatsdDataFactory();
140 if ( $this->timing ===
null ) {
141 $this->timing =
new Timing( [
142 'logger' => LoggerFactory::getInstance(
'Timing' )
154 $this->wikipage =
null;
161 if ( $this->title ===
null ) {
162 global
$wgTitle; # fallback to $wg till we can improve
this
166 __METHOD__ .
' called by ' .
wfGetAllCallers( 5 ) .
' with no title set.'
180 return $this->title !==
null;
192 if ( $this->wikipage ) {
199 return $title ? $title->canExist() :
false;
207 $pageTitle = $wikiPage->getTitle();
208 if ( !$this->
hasTitle() || !$pageTitle->equals( $this->getTitle() ) ) {
212 $this->wikipage = $wikiPage;
226 if ( $this->wikipage ===
null ) {
228 if ( $title ===
null ) {
229 throw new MWException( __METHOD__ .
' called without Title object set' );
231 $this->wikipage = WikiPage::factory( $title );
248 if ( $this->
output ===
null ) {
266 if ( $this->user ===
null ) {
299 if ( $language instanceof
Language ) {
300 $this->lang = $language;
301 } elseif ( is_string( $language ) ) {
303 $obj = Language::factory( $language );
306 throw new MWException( __METHOD__ .
" was passed an invalid type of data." );
318 if ( isset( $this->recursion ) ) {
319 trigger_error(
"Recursion detected in " . __METHOD__, E_USER_WARNING );
321 wfDebugLog(
'recursion-guard',
"Recursion detected:\n" .
$e->getTraceAsString() );
324 $this->lang = Language::factory(
$code );
325 } elseif ( $this->lang ===
null ) {
326 $this->recursion =
true;
335 if (
$code ===
'user' ) {
336 $code = $user->getOption(
'language' );
340 Hooks::run(
'UserGetLanguageObject', [ $user, &
$code, $this ] );
345 $obj = Language::factory(
$code );
349 unset( $this->recursion );
351 catch ( Exception $ex ) {
352 unset( $this->recursion );
365 $this->
skin->setContext( $this );
372 if ( $this->
skin ===
null ) {
374 Hooks::run(
'RequestContextCreateSkin', [ $this, &$skin ] );
375 $factory = SkinFactory::getDefaultInstance();
378 if ( $skin instanceof
Skin ) {
380 } elseif ( is_string( $skin ) ) {
382 $normalized = Skin::normalizeKey( $skin );
383 $this->
skin = $factory->makeSkin( $normalized );
388 if ( $this->
skin ===
null ) {
389 if ( !in_array(
'skin', $this->
getConfig()->
get(
'HiddenPrefs' ) ) ) {
391 $userSkin = $this->
getUser()->getOption(
'skin' );
392 $userSkin = $this->
getRequest()->getVal(
'useskin', $userSkin );
394 # if we're not allowing users to override, then use the default
395 $userSkin = $this->
getConfig()->get(
'DefaultSkin' );
400 $normalized = Skin::normalizeKey( $userSkin );
404 $this->
skin = $factory->makeSkin( $normalized );
408 $this->
skin->setContext( $this );
423 public function msg( $key ) {
424 $args = func_get_args();
426 return call_user_func_array(
'wfMessage',
$args )->setContext( $this );
435 if ( self::$instance ===
null ) {
436 self::$instance =
new self;
451 wfDebug( $func .
' called without context. ' .
452 "Using RequestContext::getMain() for sanity\n" );
461 if ( !( defined(
'MW_PHPUNIT_TEST' ) || defined(
'MW_PARSER_TEST' ) ) ) {
462 throw new MWException( __METHOD__ .
'() should be called only from unit tests!' );
464 self::$instance =
null;
475 $session = MediaWiki\Session\SessionManager::getGlobalSession();
478 'headers' => $this->
getRequest()->getAllHeaders(),
479 'sessionId' => $session->isPersistent() ? $session->getId() :
'',
480 'userId' => $this->
getUser()->getId()
507 if ( strlen(
$params[
'sessionId'] ) &&
508 MediaWiki\Session\SessionManager::getGlobalSession()->isPersistent()
512 throw new MWException(
"Sessions can only be imported when none is active." );
513 } elseif ( !IP::isValid(
$params[
'ip'] ) ) {
514 throw new MWException(
"Invalid client IP address '{$params['ip']}'." );
520 if ( !$user->getId() ) {
521 throw new MWException(
"No user with ID '{$params['userId']}'." );
533 if (
MediaWiki\Session\PHPSessionHandler::isEnabled() ) {
534 session_write_close();
541 if ( strlen(
$params[
'sessionId'] ) ) {
542 $manager = MediaWiki\Session\SessionManager::singleton();
543 $session = $manager->getSessionById(
$params[
'sessionId'],
true )
544 ?: $manager->getEmptySession();
558 if ( $session &&
MediaWiki\Session\PHPSessionHandler::isEnabled() ) {
559 session_id( $session->getId() );
560 Wikimedia\quietCall(
'session_start' );
576 $importSessionFunc( $user,
$params );
579 return new ScopedCallback(
580 function () use ( $importSessionFunc, $oUser, $oParams, $oRequest ) {
582 $importSessionFunc( $oUser, $oParams );
$wgLanguageCode
Site language code.
global $wgCommandLineMode
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfGetAllCallers( $limit=3)
Return a string consisting of callers in the stack.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
if(! $wgDBerrorLogTZ) $wgRequest
if(! $wgRequest->checkUrlExtension()) if(isset($_SERVER[ 'PATH_INFO']) &&$_SERVER[ 'PATH_INFO'] !='') if(! $wgEnableAPI) $wgTitle
WebRequest clone which takes values from a provided array.
Internationalisation code.
This class should be covered by a general architecture document which does not exist as of January 20...
Group all the pieces relevant to the context of a request into one instance.
static getMainAndWarn( $func=__METHOD__)
Get the RequestContext object associated with the main request and gives a warning to the log,...
canUseWikiPage()
Check whether a WikiPage object can be get with getWikiPage().
static importScopedSession(array $params)
Import an client IP address, HTTP headers, user ID, and session ID.
static RequestContext $instance
static sanitizeLangCode( $code)
Accepts a language code and ensures it's sane.
setConfig(Config $config)
hasTitle()
Check, if a Title object is set.
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
setTitle(Title $title=null)
static newExtraneousContext(Title $title, $request=[])
Create a new extraneous context.
exportSession()
Export the resolved user IP, HTTP headers, user ID, and session ID.
setOutput(OutputPage $output)
setWikiPage(WikiPage $wikiPage)
static resetMain()
Resets singleton returned by getMain().
static getMain()
Get the RequestContext object associated with the main request.
getLanguage()
Get the Language object.
setRequest(WebRequest $request)
getWikiPage()
Get the WikiPage object.
The main skin class which provides methods and properties for all other skins.
An interface to help developers measure the performance of their applications.
Represents a title within MediaWiki.
canExist()
Is this in a namespace that allows actual pages?
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
static newFromId( $id)
Static factory method for creation from a given user ID.
static newFromSession(WebRequest $request=null)
Create a new user object using data from session.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
getVal( $name, $default=null)
Fetch a scalar from the input or return $default if it's not set.
Class representing a MediaWiki article and history.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a skin(according to that user 's preference)
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
returning false will NOT prevent logging $e
Interface for configuration instances.
Interface for objects which can provide a MediaWiki context on request.