27use Wikimedia\ScopedCallback;
87 $this->config = $config;
94 if ( $this->config ===
null ) {
97 $this->config = MediaWikiServices::getInstance()->getMainConfig();
100 return $this->config;
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' )
145 return $this->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;
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 );
234 return $this->wikipage;
248 if ( $this->output ===
null ) {
268 if ( $this->user ===
null ) {
301 if ( $language instanceof
Language ) {
302 $this->lang = $language;
303 } elseif ( is_string( $language ) ) {
304 $language = self::sanitizeLangCode( $language );
305 $obj = Language::factory( $language );
308 throw new MWException( __METHOD__ .
" was passed an invalid type of data." );
320 if ( isset( $this->recursion ) ) {
321 trigger_error(
"Recursion detected in " . __METHOD__, E_USER_WARNING );
323 wfDebugLog(
'recursion-guard',
"Recursion detected:\n" .
$e->getTraceAsString() );
326 $this->lang = Language::factory(
$code );
327 } elseif ( $this->lang ===
null ) {
328 $this->recursion =
true;
335 if (
$code ===
'user' ) {
336 $code = $user->getOption(
'language' );
340 Hooks::run(
'UserGetLanguageObject', [ $user, &
$code, $this ] );
343 $this->lang = MediaWikiServices::getInstance()->getContentLanguage();
345 $obj = Language::factory(
$code );
349 unset( $this->recursion );
351 catch ( Exception $ex ) {
352 unset( $this->recursion );
364 $this->skin = clone
$skin;
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();
435 if ( self::$instance ===
null ) {
436 self::$instance =
new self;
439 return self::$instance;
451 wfDebug( $func .
' called without context. ' .
452 "Using RequestContext::getMain() for sanity\n" );
454 return self::getMain();
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' );
573 $oUser = self::getMain()->getUser();
574 $oParams = self::getMain()->exportSession();
575 $oRequest = self::getMain()->getRequest();
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'] !='') $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.
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...
Class representing a MediaWiki article and history.
getTitle()
Get the title object of the article.
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 $request
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
namespace and then decline to actually register it file or subcat img or subcat $title
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
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned $skin
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place $output
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
returning false will NOT prevent logging $e
Interface for configuration instances.
Interface for objects which can provide a MediaWiki context on request.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
if(!isset( $args[0])) $lang