MediaWiki master
MediaWiki\Request\FauxRequest Class Reference

WebRequest clone which takes values from a provided array. More...

Inherits MediaWiki\Request\WebRequest.

Inherited by MediaWiki\Request\DerivativeRequest.

Collaboration diagram for MediaWiki\Request\FauxRequest:

Public Member Functions

 __construct (array $data=[], $wasPosted=false, $session=null, $protocol='http')
 
 getCookie ( $key, $prefix=null, $default=null)
 Get a cookie from the $_COOKIE jar.
 
 getMethod ()
 Get the HTTP method used for this request.
 
 getPostValues ()
 Get the values passed via POST.
 
 getProtocol ()
 Get the current URL protocol (http or https)
 
 getQueryValues ()
 
 getQueryValuesOnly ()
 Get the values passed in $_GET only, not including the path router parameters.
 
 getRawInput ()
 FauxRequests shouldn't depend on raw request data (but that could be implemented here)
 
 getRawPostString ()
 FauxRequests shouldn't depend on raw request data (but that could be implemented here)
 
 getRawQueryString ()
 FauxRequests shouldn't depend on raw request data (but that could be implemented here)
 
 getRequestURL ()
 
 getSessionArray ()
 
 getText ( $name, $default='')
 
 getUpload ( $key)
 Return a MediaWiki\Request\FauxRequestUpload object corresponding to the key.
 
 hasRequestURL ()
 
 response ()
 Return a handle to WebResponse style object, for setting cookies, headers and other stuff, for Request being worked on.
 
 setCookie ( $key, $value, $prefix=null)
 
 setCookies ( $cookies, $prefix=null)
 
 setHeader ( $name, $val)
 
 setHeaders ( $headers)
 
 setRequestURL (string $url)
 
 setServerInfo (array $info)
 
 setUpload ( $key, $data)
 Set fake upload data for one file with specific key.
 
 setUploadData ( $uploadData)
 Set fake upload data for all files.
 
 wasPosted ()
 
- Public Member Functions inherited from MediaWiki\Request\WebRequest
 __construct ()
 
 appendQueryArray ( $array)
 Appends or replaces value of query variables.
 
 appendQueryValue ( $key, $value)
 
 getAcceptLang ()
 Parse the Accept-Language header sent by the client into an array.
 
 getAllHeaders ()
 Get an array containing all request headers.
 
 getArray ( $name, $default=null)
 Fetch an array from this web request's $_GET, $_POST or path router vars, or return $default if it's not set.
 
 getBool ( $name, $default=false)
 Fetch a boolean value from this web request's $_GET, $_POST or path router vars or return $default if not set.
 
 getCheck ( $name)
 Return true if the named value is set in this web request's $_GET, $_POST or path router vars, whatever that value is (even "0").
 
 getCrossSiteCookie ( $key, $prefix='', $default=null)
 Get a cookie set with SameSite=None.
 
 getElapsedTime ()
 Get the number of seconds to have elapsed since request start, in fractional seconds, with microsecond resolution.
 
 getFileName ( $key)
 Return the original filename of the uploaded file, as reported by the submitting user agent.
 
 getFileTempname ( $key)
 Return the path to the temporary file where PHP has stored the upload.
 
 getFloat ( $name, $default=0.0)
 Fetch a floating point value from this web request's $_GET, $_POST or path router vars, or return $default if not set.
 
 getFullRequestURL ()
 Return the request URI with the canonical service and hostname, path, and query string.
 
 getFuzzyBool ( $name, $default=false)
 Fetch a boolean value from this web request's $_GET, $_POST or path router vars or return $default if not set.
 
 getHeader ( $name, $flags=0)
 Get a request header, or false if it isn't set.
 
 getInt ( $name, $default=0)
 Fetch an integer value from this web request's $_GET, $_POST or path router vars, or return $default if not set.
 
 getIntArray ( $name, $default=null)
 Fetch an array of integers from this web request's $_GET, $_POST or path router vars, or return $default if it's not set.
 
 getIntOrNull ( $name)
 Fetch an integer value from this web request's $_GET, $_POST or path router vars, or return null if empty.
 
 getIP ()
 Work out the IP address based on various globals For trusted proxies, use the XFF client IP (first of the chain)
 
 getLimitOffsetForUser (UserIdentity $user, $deflimit=50, $optionname='rclimit')
 Check for limit and offset parameters on the input, and return sensible defaults if not given.
 
 getRawVal ( $name, $default=null)
 Fetch a string from this web request's $_GET, $_POST or path router vars WITHOUT any Unicode or line break normalization.
 
 getSession ()
 Return the session for this request.
 
 getSessionData ( $key)
 Get data from the session.
 
 getSessionId ()
 Get the session id for this request, if any.
 
 getUploadError ( $key)
 Return the upload error or 0.
 
 getVal ( $name, $default=null)
 Fetch a text string from this web request's $_GET, $_POST or path router vars and partially normalize it.
 
 getValueNames ( $exclude=[])
 Returns the names of this web request's $_GET, $_POST or path router vars, excluding those in $exclude.
 
 getValues (... $names)
 Extracts the (given) named values from this web request's $_GET, $_POST or path router vars into an array.
 
 hasSafeMethod ()
 Check if this request uses a "safe" HTTP method.
 
 interpolateTitle ()
 Check for title, action, and/or variant data in the URL and interpolate it into the GET variables.
 
 isSafeRequest ()
 Whether this request should be identified as being "safe".
 
 markAsSafeRequest ()
 Mark this request as identified as being nullipotent even if it is a POST request.
 
 matchURLForCDN (array $cdnUrls)
 Determine if the request URL matches one of a given set of canonical CDN URLs.
 
 normalizeUnicode ( $data)
 Recursively normalizes UTF-8 strings in the given array.
 
 setIP ( $ip)
 
 setSessionData ( $key, $data)
 
 setSessionId (SessionId $sessionId)
 Set the session for this request.
 
 setVal ( $key, $value)
 Set an arbitrary value into our get/post data.
 
 unsetVal ( $key)
 Unset an arbitrary value from our get/post data.
 

Protected Member Functions

 getRawIP ()
 
 getServerInfo ( $name, $default=null)
 
 initHeaders ()
 Initialise the header list.
 
- Protected Member Functions inherited from MediaWiki\Request\WebRequest
 getPathInfo ( $want='all')
 Extract relevant query arguments from the http request uri's path to be merged with the normal php provided query arguments.
 
 getServerInfo (string $name, ?string $default=null)
 Returns an entry from the $_SERVER array.
 

Protected Attributes

array $cookies = []
 
- Protected Attributes inherited from MediaWiki\Request\WebRequest
array $data
 The parameters from $_GET, $_POST and the path router.
 
string[] $headers = []
 Lazy-initialized request headers indexed by upper-case header name.
 
bool $markedAsSafe = false
 Whether this HTTP request is "safe" (even if it is an HTTP post)
 
string $protocol
 Cached URL protocol.
 
string string[][] $queryAndPathParams
 The parameters from $_GET.
 
string string[][] $queryParams
 The parameters from $_GET only.
 
float $requestTime
 The timestamp of the start of the request, with microsecond precision.
 
WebResponse WebResponse $response = null
 Lazy-init response object.
 
SessionId null $sessionId = null
 Session ID to use for this request.
 

Additional Inherited Members

- Static Public Member Functions inherited from MediaWiki\Request\WebRequest
static canonicalizeIPv6LoopbackAddress ( $ip)
 Converts ::1 (IPv6 loopback address) to 127.0.0.1 (IPv4 loopback address); assists in matching trusted proxies.
 
static detectProtocol ()
 Detect the protocol from $_SERVER.
 
static detectServer ( $assumeProxiesUseDefaultProtocolPorts=null)
 Work out an appropriate URL prefix containing scheme and host, based on information detected from $_SERVER.
 
static extractTitle ( $path, $bases, $key=false)
 URL rewriting function; tries to extract page title and, optionally, one other fixed parameter value from a URL path.
 
static getGlobalRequestURL ()
 Return the path and query string portion of the main request URI.
 
static getRequestId ()
 Get the current request ID.
 
static getRequestPathSuffix (string $basePath, ?string $requestUrl=null)
 If the request URL matches a given base path, extract the path part of the request URL after that base, and decode escape sequences in it.
 
static overrideRequestId ( $newId)
 Override the unique request ID.
 
- Public Attributes inherited from MediaWiki\Request\WebRequest
const GETHEADER_LIST = 1
 Flag to make WebRequest::getHeader return an array of values.
 

Detailed Description

WebRequest clone which takes values from a provided array.

Stability: newable

Definition at line 42 of file FauxRequest.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Request\FauxRequest::__construct ( array $data = [],
$wasPosted = false,
$session = null,
$protocol = 'http' )
Stability: stable
to call
Parameters
array$dataArray of non-urlencoded key => value pairs, the fake GET/POST values
bool$wasPostedWhether to treat the data as POST
MediaWiki\\Session\\Session | array | null$sessionSession, session data array, or null
string$protocol'http' or 'https'

Definition at line 60 of file FauxRequest.php.

References MediaWiki\Request\WebRequest\$data, MediaWiki\Request\WebRequest\$protocol, and MediaWiki\Request\FauxRequest\wasPosted().

Member Function Documentation

◆ getCookie()

MediaWiki\Request\FauxRequest::getCookie ( $key,
$prefix = null,
$default = null )

Get a cookie from the $_COOKIE jar.

Parameters
string$keyThe name of the cookie
string | null$prefixA prefix to use for the cookie name, if not $wgCookiePrefix
mixed | null$defaultWhat to return if the value isn't found
Returns
mixed Cookie value or $default if the cookie not set

Reimplemented from MediaWiki\Request\WebRequest.

Reimplemented in MediaWiki\Request\DerivativeRequest.

Definition at line 133 of file FauxRequest.php.

References MediaWiki\MainConfigNames\CookiePrefix, and MediaWiki\MediaWikiServices\getInstance().

◆ getMethod()

MediaWiki\Request\FauxRequest::getMethod ( )

Get the HTTP method used for this request.

Returns
string

Reimplemented from MediaWiki\Request\WebRequest.

Definition at line 122 of file FauxRequest.php.

◆ getPostValues()

MediaWiki\Request\FauxRequest::getPostValues ( )

Get the values passed via POST.

No transformation is performed on the values.

Since
1.32
Returns
(string|string[])[] Might contain arrays in case there was a &param[]=… parameter

Reimplemented from MediaWiki\Request\WebRequest.

Definition at line 293 of file FauxRequest.php.

◆ getProtocol()

MediaWiki\Request\FauxRequest::getProtocol ( )

Get the current URL protocol (http or https)

Returns
string

Reimplemented from MediaWiki\Request\WebRequest.

Reimplemented in MediaWiki\Request\DerivativeRequest.

Definition at line 260 of file FauxRequest.php.

◆ getQueryValues()

MediaWiki\Request\FauxRequest::getQueryValues ( )
Returns
array

Reimplemented from MediaWiki\Request\WebRequest.

Definition at line 110 of file FauxRequest.php.

◆ getQueryValuesOnly()

MediaWiki\Request\FauxRequest::getQueryValuesOnly ( )

Get the values passed in $_GET only, not including the path router parameters.

This is less suitable for self-links to index.php but useful for other entry points. No transformation is performed on the values.

Since
1.34
Returns
(string|string[])[] Might contain arrays in case there was a &param[]=… parameter

Reimplemented from MediaWiki\Request\WebRequest.

Definition at line 118 of file FauxRequest.php.

◆ getRawInput()

MediaWiki\Request\FauxRequest::getRawInput ( )

FauxRequests shouldn't depend on raw request data (but that could be implemented here)

Returns
string

Reimplemented from MediaWiki\Request\WebRequest.

Definition at line 317 of file FauxRequest.php.

◆ getRawIP()

MediaWiki\Request\FauxRequest::getRawIP ( )
protected
Returns
string

Reimplemented from MediaWiki\Request\WebRequest.

Definition at line 325 of file FauxRequest.php.

◆ getRawPostString()

MediaWiki\Request\FauxRequest::getRawPostString ( )

FauxRequests shouldn't depend on raw request data (but that could be implemented here)

Returns
string

Reimplemented from MediaWiki\Request\WebRequest.

Definition at line 309 of file FauxRequest.php.

◆ getRawQueryString()

MediaWiki\Request\FauxRequest::getRawQueryString ( )

FauxRequests shouldn't depend on raw request data (but that could be implemented here)

Returns
string

Reimplemented from MediaWiki\Request\WebRequest.

Definition at line 301 of file FauxRequest.php.

◆ getRequestURL()

MediaWiki\Request\FauxRequest::getRequestURL ( )
Returns
string

Reimplemented from MediaWiki\Request\WebRequest.

Definition at line 253 of file FauxRequest.php.

◆ getServerInfo()

MediaWiki\Request\FauxRequest::getServerInfo ( $name,
$default = null )
protected

Definition at line 238 of file FauxRequest.php.

◆ getSessionArray()

MediaWiki\Request\FauxRequest::getSessionArray ( )
Returns
array|null

Definition at line 286 of file FauxRequest.php.

◆ getText()

MediaWiki\Request\FauxRequest::getText ( $name,
$default = '' )
Parameters
string$name
string$default
Returns
string

Reimplemented from MediaWiki\Request\WebRequest.

Definition at line 102 of file FauxRequest.php.

◆ getUpload()

MediaWiki\Request\FauxRequest::getUpload ( $key)

Return a MediaWiki\Request\FauxRequestUpload object corresponding to the key.

Parameters
string$key
Returns
FauxRequestUpload

Reimplemented from MediaWiki\Request\WebRequest.

Reimplemented in MediaWiki\Request\DerivativeRequest.

Definition at line 213 of file FauxRequest.php.

◆ hasRequestURL()

MediaWiki\Request\FauxRequest::hasRequestURL ( )
Since
1.42
Returns
bool

Definition at line 234 of file FauxRequest.php.

◆ initHeaders()

MediaWiki\Request\FauxRequest::initHeaders ( )
protected

Initialise the header list.

Reimplemented from MediaWiki\Request\WebRequest.

Definition at line 93 of file FauxRequest.php.

◆ response()

MediaWiki\Request\FauxRequest::response ( )

Return a handle to WebResponse style object, for setting cookies, headers and other stuff, for Request being worked on.

Reimplemented from MediaWiki\Request\WebRequest.

Definition at line 82 of file FauxRequest.php.

References MediaWiki\Request\FauxRequest\response().

Referenced by MediaWiki\Request\FauxRequest\response().

◆ setCookie()

MediaWiki\Request\FauxRequest::setCookie ( $key,
$value,
$prefix = null )
Parameters
string$keyUnprefixed name of the cookie to set
string | null$valueValue of the cookie to set
string | null$prefixCookie prefix. Defaults to $wgCookiePrefix
Since
1.26

Definition at line 148 of file FauxRequest.php.

◆ setCookies()

MediaWiki\Request\FauxRequest::setCookies ( $cookies,
$prefix = null )
Parameters
array$cookies
string | null$prefixCookie prefix. Defaults to $wgCookiePrefix
Since
1.26

Definition at line 157 of file FauxRequest.php.

References MediaWiki\MainConfigNames\CookiePrefix, and MediaWiki\MediaWikiServices\getInstance().

◆ setHeader()

MediaWiki\Request\FauxRequest::setHeader ( $name,
$val )
Parameters
string$name
string$val

Definition at line 268 of file FauxRequest.php.

◆ setHeaders()

MediaWiki\Request\FauxRequest::setHeaders ( $headers)
Parameters
array$headers
Since
1.26

Definition at line 276 of file FauxRequest.php.

◆ setRequestURL()

MediaWiki\Request\FauxRequest::setRequestURL ( string $url)
Parameters
string$url
Since
1.25

Definition at line 222 of file FauxRequest.php.

◆ setServerInfo()

MediaWiki\Request\FauxRequest::setServerInfo ( array $info)
See also
$_SERVER
Parameters
array$info

Definition at line 246 of file FauxRequest.php.

◆ setUpload()

MediaWiki\Request\FauxRequest::setUpload ( $key,
$data )

Set fake upload data for one file with specific key.

Parameters
string$key
array | WebRequestUpload$data
Since
1.37

Definition at line 187 of file FauxRequest.php.

References MediaWiki\Request\WebRequestUpload\REQUIRED_FILEINFO_KEYS.

◆ setUploadData()

MediaWiki\Request\FauxRequest::setUploadData ( $uploadData)

Set fake upload data for all files.

Parameters
(array|WebRequestUpload)[]$uploadData
Since
1.37

Definition at line 174 of file FauxRequest.php.

◆ wasPosted()

MediaWiki\Request\FauxRequest::wasPosted ( )
Returns
bool

Reimplemented from MediaWiki\Request\WebRequest.

Definition at line 129 of file FauxRequest.php.

Referenced by MediaWiki\Request\FauxRequest\__construct().

Member Data Documentation

◆ $cookies

array MediaWiki\Request\FauxRequest::$cookies = []
protected

Definition at line 47 of file FauxRequest.php.


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