MediaWiki  1.32.5
FauxRequest Class Reference

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

Inheritance diagram for FauxRequest:
Collaboration diagram for FauxRequest:

Public Member Functions

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

Protected Member Functions

 getRawIP ()
 
 initHeaders ()
 Initialise the header list. More...
 
- Protected Member Functions inherited from WebRequest
 doSecurityRedirect ( $url)
 Attempt to redirect to a URL with a QUERY_STRING that's not dangerous in IE 6. More...
 

Protected Attributes

 $cookies = []
 
- Protected Attributes inherited from WebRequest
 $data
 
bool $markedAsSafe = false
 Whether this HTTP request is "safe" (even if it is an HTTP post) More...
 
string $protocol
 Cached URL protocol. More...
 
float $requestTime
 The timestamp of the start of the request, with microsecond precision. More...
 
SessionId null $sessionId = null
 Session ID to use for this request. More...
 

Private Attributes

 $requestUrl
 
 $wasPosted = false
 

Additional Inherited Members

- Static Public Member Functions inherited from WebRequest
static detectProtocol ()
 Detect the protocol from $_SERVER. More...
 
static detectServer ()
 Work out an appropriate URL prefix containing scheme and host, based on information detected from $_SERVER. More...
 
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. More...
 
static getGlobalRequestURL ()
 Return the path and query string portion of the main request URI. More...
 
static getPathInfo ( $want='all')
 Extract relevant query arguments from the http request uri's path to be merged with the normal php provided query arguments. More...
 
static getRequestId ()
 Get the unique request ID. More...
 
static overrideRequestId ( $id)
 Override the unique request ID. More...
 
- Public Attributes inherited from WebRequest
 $headers = []
 
const GETHEADER_LIST = 1
 Flag to make WebRequest::getHeader return an array of values. More...
 

Detailed Description

WebRequest clone which takes values from a provided array.

Definition at line 33 of file FauxRequest.php.

Constructor & Destructor Documentation

◆ __construct()

FauxRequest::__construct (   $data = [],
  $wasPosted = false,
  $session = null,
  $protocol = 'http' 
)
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'
Exceptions
MWException

Definition at line 47 of file FauxRequest.php.

References WebRequest\$data, WebRequest\$protocol, $value, $wasPosted, as, data, and wasPosted().

Member Function Documentation

◆ checkUrlExtension()

FauxRequest::checkUrlExtension (   $extWhitelist = [])
Parameters
array$extWhitelist
Returns
bool

Reimplemented from WebRequest.

Definition at line 235 of file FauxRequest.php.

◆ getCookie()

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 WebRequest.

Reimplemented in DerivativeRequest.

Definition at line 118 of file FauxRequest.php.

References $name, and $wgCookiePrefix.

◆ getMethod()

FauxRequest::getMethod ( )

Get the HTTP method used for this request.

Returns
string

Reimplemented from WebRequest.

Definition at line 107 of file FauxRequest.php.

References wasPosted().

◆ getProtocol()

FauxRequest::getProtocol ( )

Get the current URL protocol (http or https)

Returns
string

Reimplemented from WebRequest.

Reimplemented in DerivativeRequest.

Definition at line 173 of file FauxRequest.php.

References WebRequest\$protocol.

◆ getQueryValues()

FauxRequest::getQueryValues ( )
Returns
array

Reimplemented from WebRequest.

Definition at line 99 of file FauxRequest.php.

References WebRequest\$data, and wasPosted().

◆ getRawInput()

FauxRequest::getRawInput ( )

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

Returns
string

Reimplemented from WebRequest.

Definition at line 226 of file FauxRequest.php.

◆ getRawIP()

FauxRequest::getRawIP ( )
protected
Returns
string

Reimplemented from WebRequest.

Definition at line 243 of file FauxRequest.php.

◆ getRawPostString()

FauxRequest::getRawPostString ( )

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

Returns
string

Reimplemented from WebRequest.

Definition at line 218 of file FauxRequest.php.

◆ getRawQueryString()

FauxRequest::getRawQueryString ( )

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

Returns
string

Reimplemented from WebRequest.

Definition at line 210 of file FauxRequest.php.

◆ getRequestURL()

FauxRequest::getRequestURL ( )
Since
1.25 MWException( "getRequestURL not implemented" ) no longer thrown.
Returns
string

Reimplemented from WebRequest.

Definition at line 166 of file FauxRequest.php.

References $requestUrl.

◆ getSessionArray()

FauxRequest::getSessionArray ( )
Returns
array|null

Definition at line 199 of file FauxRequest.php.

References WebRequest\getSession().

◆ getText()

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

Reimplemented from WebRequest.

Definition at line 84 of file FauxRequest.php.

References $name, and WebRequest\getVal().

◆ getValues()

FauxRequest::getValues ( )
Returns
array

Reimplemented from WebRequest.

Definition at line 92 of file FauxRequest.php.

References WebRequest\$data.

◆ initHeaders()

FauxRequest::initHeaders ( )
protected

Initialise the header list.

Reimplemented from WebRequest.

Definition at line 75 of file FauxRequest.php.

◆ setCookie()

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

Definition at line 133 of file FauxRequest.php.

References $value, and setCookies().

◆ setCookies()

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

Definition at line 142 of file FauxRequest.php.

References $cookies, $name, $value, $wgCookiePrefix, and as.

Referenced by setCookie().

◆ setHeader()

FauxRequest::setHeader (   $name,
  $val 
)
Parameters
string$name
string$val

Definition at line 181 of file FauxRequest.php.

References $name, and setHeaders().

◆ setHeaders()

FauxRequest::setHeaders (   $headers)
Since
1.26
Parameters
array$headers

Definition at line 189 of file FauxRequest.php.

References WebRequest\$headers, $name, and as.

Referenced by setHeader().

◆ setRequestURL()

FauxRequest::setRequestURL (   $url)
Since
1.25
Parameters
string$url

Definition at line 157 of file FauxRequest.php.

◆ wasPosted()

FauxRequest::wasPosted ( )
Returns
bool

Reimplemented from WebRequest.

Definition at line 114 of file FauxRequest.php.

References $wasPosted.

Referenced by __construct(), getMethod(), and getQueryValues().

Member Data Documentation

◆ $cookies

FauxRequest::$cookies = []
protected

Definition at line 36 of file FauxRequest.php.

Referenced by setCookies().

◆ $requestUrl

FauxRequest::$requestUrl
private

Definition at line 35 of file FauxRequest.php.

Referenced by getRequestURL().

◆ $wasPosted

FauxRequest::$wasPosted = false
private

Definition at line 34 of file FauxRequest.php.

Referenced by DerivativeRequest\__construct(), __construct(), and wasPosted().


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