BlueSpice MediaWiki REL1_27
 All Classes Namespaces Files Functions Variables Groups Pages
RequestContext Class Reference
Inheritance diagram for RequestContext:
Collaboration diagram for RequestContext:

Public Member Functions

 setConfig (Config $c)
 
 getConfig ()
 
 setRequest (WebRequest $r)
 
 getRequest ()
 
 getStats ()
 
 getTiming ()
 
 setTitle (Title $title=null)
 
 getTitle ()
 
 hasTitle ()
 
 canUseWikiPage ()
 
 setWikiPage (WikiPage $p)
 
 getWikiPage ()
 
 setOutput (OutputPage $o)
 
 getOutput ()
 
 setUser (User $u)
 
 getUser ()
 
 setLanguage ($l)
 
 getLanguage ()
 
 setSkin (Skin $s)
 
 getSkin ()
 
 msg ()
 
 exportSession ()
 

Static Public Member Functions

static sanitizeLangCode ($code)
 
static getMain ()
 
static getMainAndWarn ($func=__METHOD__)
 
static resetMain ()
 
static importScopedSession (array $params)
 
static newExtraneousContext (Title $title, $request=[])
 

Detailed Description

Group all the pieces relevant to the context of a request into one instance

Member Function Documentation

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.

Since
1.19
Returns
bool

Implements IContextSource.

RequestContext::exportSession ( )

Export the resolved user IP, HTTP headers, user ID, and session ID. The result will be reasonably sized to allow for serialization.

Returns
array
Since
1.21

Implements IContextSource.

RequestContext::getConfig ( )

Get the Config object

Returns
Config

Implements IContextSource.

RequestContext::getLanguage ( )

Get the Language object. Initialization of user or request objects can depend on this.

Returns
Language
Exceptions
Exception
Since
1.19

Implements IContextSource.

static RequestContext::getMain ( )
static

Static methods Get the RequestContext object associated with the main request

Returns
RequestContext
static RequestContext::getMainAndWarn (   $func = __METHOD__)
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.

Parameters
string$func
Returns
RequestContext
Since
1.24
RequestContext::getOutput ( )

Get the OutputPage object

Returns
OutputPage

Implements IContextSource.

RequestContext::getRequest ( )

Get the WebRequest object

Returns
WebRequest

Implements IContextSource.

RequestContext::getSkin ( )

Get the Skin object

Returns
Skin

Implements IContextSource.

RequestContext::getStats ( )

Get the Stats object

Deprecated:
since 1.27 use a StatsdDataFactory from MediaWikiServices (preferably injected)
Returns
StatsdDataFactory

Implements IContextSource.

RequestContext::getTiming ( )

Get the timing object

Returns
Timing

Implements IContextSource.

RequestContext::getTitle ( )

Get the Title object

Returns
Title|null

Implements IContextSource.

RequestContext::getUser ( )

Get the User object

Returns
User

Implements IContextSource.

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.

Since
1.19
Exceptions
MWException
Returns
WikiPage

Implements IContextSource.

RequestContext::hasTitle ( )

Check, if a Title object is set

Since
1.25
Returns
bool
static RequestContext::importScopedSession ( array  $params)
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.

Note
suhosin.session.encrypt may interfere with this method.
Parameters
array$paramsResult of RequestContext::exportSession()
Returns
ScopedCallback
Exceptions
MWException
Since
1.21
RequestContext::msg ( )

Helpful methods Get a Message object with context set Parameters are the same as wfMessage()

Parameters
mixed...
Returns
Message

Implements IContextSource.

static RequestContext::newExtraneousContext ( Title  $title,
  $request = [] 
)
static

Create a new extraneous context. The context is filled with information external to the current session.

  • Title is specified by argument
  • Request is a FauxRequest, or a FauxRequest can be specified by argument
  • User is an anonymous user, for separation IPv4 localhost is used
  • Language will be based on the anonymous user and request, may be content language or a uselang param in the fauxrequest data may change the lang
  • Skin will be based on the anonymous user, should be the wiki's default skin
Parameters
Title$titleTitle to use for the extraneous request
WebRequest | array$requestA WebRequest or data to use for a FauxRequest
Returns
RequestContext
static RequestContext::resetMain ( )
static

Resets singleton returned by getMain(). Should be called only from unit tests.

static RequestContext::sanitizeLangCode (   $code)
static

Accepts a language code and ensures it's sane. Outputs a cleaned up language code and replaces with $wgLanguageCode if not sane.

Parameters
string$codeLanguage code
Returns
string
RequestContext::setConfig ( Config  $c)

Set the Config object

Parameters
Config$c

Implements MutableContext.

RequestContext::setLanguage (   $l)

Set the Language object

Parameters
Language | string$lLanguage instance or language code
Exceptions
MWException
Since
1.19

Implements MutableContext.

RequestContext::setOutput ( OutputPage  $o)
Parameters
OutputPage$o

Implements MutableContext.

RequestContext::setRequest ( WebRequest  $r)

Set the WebRequest object

Parameters
WebRequest$r

Implements MutableContext.

RequestContext::setSkin ( Skin  $s)

Set the Skin object

Parameters
Skin$s

Implements MutableContext.

RequestContext::setTitle ( Title  $title = null)

Set the Title object

Parameters
Title$title

Implements MutableContext.

RequestContext::setUser ( User  $u)

Set the User object

Parameters
User$u

Implements MutableContext.

RequestContext::setWikiPage ( WikiPage  $p)

Set the WikiPage object

Since
1.19
Parameters
WikiPage$p

Implements MutableContext.


The documentation for this class was generated from the following file: