MediaWiki  1.23.2
WebRequest Class Reference

The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form, handling remove of "magic quotes" slashes, stripping illegal input characters and normalizing Unicode sequences. More...

Inheritance diagram for WebRequest:
Collaboration diagram for WebRequest:

Public Member Functions

 __construct ()
 
 appendQuery ( $query)
 Take an arbitrary query and rewrite the present URL to include it. More...
 
 appendQueryArray ( $array, $onlyquery=false)
 Appends or replaces value of query variables. More...
 
 appendQueryValue ( $key, $value, $onlyquery=false)
 
 checkSessionCookie ()
 Returns true if there is a session cookie set. More...
 
 checkUrlExtension ( $extWhitelist=array())
 Check if Internet Explorer will detect an incorrect cache extension in PATH_INFO or QUERY_STRING. More...
 
 escapeAppendQuery ( $query)
 HTML-safe version of appendQuery(). More...
 
 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...
 
 getCookie ( $key, $prefix=null, $default=null)
 Get a cookie from the $_COOKIE jar. 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)
 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)
 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...
 
 getMethod ()
 Get the HTTP method used for this request. More...
 
 getProtocol ()
 Get the current URL protocol (http or https) More...
 
 getQueryValues ()
 Get the values passed in the query string. More...
 
 getRawInput ()
 Return the raw request body, with no processing. More...
 
 getRawPostString ()
 Return the contents of the POST with no decoding. More...
 
 getRawQueryString ()
 Return the contents of the Query with no decoding. More...
 
 getRequestURL ()
 Return the path and query string portion of the request URI. More...
 
 getSessionData ( $key)
 Get data from $_SESSION. More...
 
 getText ( $name, $default='')
 Fetch a text string from the given array or return $default if it's not set. 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=array())
 Returns the names of all input values excluding those in $exclude. More...
 
 getValues ()
 Extracts the given named values into an array. More...
 
 interpolateTitle ()
 Check for title, action, and/or variant data in the URL and interpolate it into the GET variables. 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...
 
 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...
 
 wasPosted ()
 Returns true if the present request was reached by a POST operation, false otherwise (GET, HEAD, or command-line). More...
 

Static Public Member Functions

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

Public Attributes

 $headers = array()
 

Protected Member Functions

 doSecurityRedirect ( $url)
 Attempt to redirect to a URL with a QUERY_STRING that's not dangerous in IE 6. More...
 
 getRawIP ()
 Fetch the raw IP from the request. More...
 

Protected Attributes

 $data
 
string $protocol
 Cached URL protocol. More...
 

Private Member Functions

 checkMagicQuotes ()
 If magic_quotes_gpc option is on, run the global arrays through fix_magic_quotes to strip out the stupid slashes. More...
 
fix_magic_quotes (&$arr, $topLevel=true)
 Recursively strips slashes from the given array; used for undoing the evil that is magic_quotes_gpc. More...
 
 getGPCVal ( $arr, $name, $default)
 Fetch a value from the given array or return $default if it's not set. More...
 
 initHeaders ()
 Initialise the header list. More...
 

Private Attributes

String $ip
 Cached client IP address. More...
 
WebResponse $response
 Lazy-init response object. More...
 

Detailed Description

The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form, handling remove of "magic quotes" slashes, stripping illegal input characters and normalizing Unicode sequences.

Usually this is used via a global singleton, $wgRequest. You should not create a second WebRequest object; make a FauxRequest object if you want to pass arbitrary data to some function in place of the web input.

Definition at line 38 of file WebRequest.php.

Constructor & Destructor Documentation

◆ __construct()

WebRequest::__construct ( )

Definition at line 56 of file WebRequest.php.

References checkMagicQuotes(), and data.

Member Function Documentation

◆ appendQuery()

WebRequest::appendQuery (   $query)

Take an arbitrary query and rewrite the present URL to include it.

Parameters
string$queryquery string fragment; do not include initial '?'
Returns
String

Definition at line 748 of file WebRequest.php.

References $query, appendQueryArray(), and wfCgiToArray().

Referenced by escapeAppendQuery().

◆ appendQueryArray()

WebRequest::appendQueryArray (   $array,
  $onlyquery = false 
)

Appends or replaces value of query variables.

Parameters
array$arrayof values to replace/add to query
bool$onlyquerywhether to only return the query string and not the complete URL
Returns
String

Definition at line 781 of file WebRequest.php.

References $query, $wgTitle, getQueryValues(), global, and wfArrayToCgi().

Referenced by appendQuery(), and appendQueryValue().

◆ appendQueryValue()

WebRequest::appendQueryValue (   $key,
  $value,
  $onlyquery = false 
)
Parameters
$key
$value
$onlyquerybool
Returns
String

Definition at line 769 of file WebRequest.php.

References $value, appendQueryArray(), and array().

◆ checkMagicQuotes()

WebRequest::checkMagicQuotes ( )
private

If magic_quotes_gpc option is on, run the global arrays through fix_magic_quotes to strip out the stupid slashes.

WARNING: This should only be done once! Running a second time could damage the values.

Definition at line 303 of file WebRequest.php.

References fix_magic_quotes().

Referenced by __construct().

◆ checkSessionCookie()

WebRequest::checkSessionCookie ( )

Returns true if there is a session cookie set.

This does not necessarily mean that the user is logged in!

If you want to check for an open session, use session_id() instead; that will also tell you if the session was opened during the current request (in which case the cookie will be sent back to the client at the end of the script run).

Returns
Boolean

Reimplemented in DerivativeRequest, and FauxRequest.

Definition at line 666 of file WebRequest.php.

◆ checkUrlExtension()

WebRequest::checkUrlExtension (   $extWhitelist = array())

Check if Internet Explorer will detect an incorrect cache extension in PATH_INFO or QUERY_STRING.

If the request can't be allowed, show an error message or redirect to a safer URL. Returns true if the URL is OK, and false if an error message has been shown and the request should be aborted.

Parameters
$extWhitelistarray
Exceptions
HttpError
Returns
bool

Reimplemented in FauxRequest.

Definition at line 971 of file WebRequest.php.

References IEUrlExtension\areServerVarsBad(), doSecurityRedirect(), IEUrlExtension\fixUrlForIE6(), getFullRequestURL(), global, and wasPosted().

◆ detectProtocol()

static WebRequest::detectProtocol ( )
static

Detect the protocol from $_SERVER.

This is for use prior to Setup.php, when no WebRequest object is available. At other times, use the non-static function getProtocol().

Returns
array

Definition at line 202 of file WebRequest.php.

Referenced by detectServer(), and getProtocol().

◆ detectServer()

static WebRequest::detectServer ( )
static

Work out an appropriate URL prefix containing scheme and host, based on information detected from $_SERVER.

Returns
string

Definition at line 165 of file WebRequest.php.

References array(), as, IP\combineHostAndPort(), detectProtocol(), and IP\splitHostAndPort().

Referenced by WebInstaller\envGetDefaultServer(), and WebRequestTest\testDetectServer().

◆ doSecurityRedirect()

WebRequest::doSecurityRedirect (   $url)
protected

Attempt to redirect to a URL with a QUERY_STRING that's not dangerous in IE 6.

Returns true if it was successful, false otherwise.

Parameters
$urlstring
Returns
bool

Definition at line 996 of file WebRequest.php.

References redirect, and title.

Referenced by checkUrlExtension().

◆ escapeAppendQuery()

WebRequest::escapeAppendQuery (   $query)

HTML-safe version of appendQuery().

Deprecated:
: Deprecated in 1.20, warnings in 1.21, remove in 1.22.
Parameters
string$queryquery string fragment; do not include initial '?'
Returns
String

Definition at line 759 of file WebRequest.php.

References $query, and appendQuery().

◆ extractTitle()

static WebRequest::extractTitle (   $path,
  $bases,
  $key = false 
)
static

URL rewriting function; tries to extract page title and, optionally, one other fixed parameter value from a URL path.

Parameters
string$paththe URL path given from the client
array$basesone or more URLs, optionally with $1 at the end
string$keyif provided, the matching key in $bases will be passed on as the value of this URL parameter
Returns
array of URL variables to interpolate; empty if no match

Definition at line 252 of file WebRequest.php.

References $matches, $path, array(), and as.

◆ fix_magic_quotes()

& WebRequest::fix_magic_quotes ( $arr,
  $topLevel = true 
)
private

Recursively strips slashes from the given array; used for undoing the evil that is magic_quotes_gpc.

Parameters
array$arrwill be modified
bool$topLevelSpecifies if the array passed is from the top level of the source. In PHP5 magic_quotes only escapes the first level of keys that belong to an array.
Returns
array the original array
See also
http://www.php.net/manual/en/function.get-magic-quotes-gpc.php#49612

Definition at line 282 of file WebRequest.php.

References array(), and as.

Referenced by checkMagicQuotes().

◆ getAcceptLang()

WebRequest::getAcceptLang ( )

Parse the Accept-Language header sent by the client into an array.

Returns
array array( languageCode => q-value ) sorted by q-value in descending order then appearing time in the header in ascending order. May contain the "language" '*', which applies to languages other than those explicitly listed. This is aligned with rfc2616 section 14.4 Preference for earlier languages appears in rfc3282 as an extension to HTTP/1.1.

Reimplemented in DerivativeRequest.

Definition at line 1030 of file WebRequest.php.

◆ getAllHeaders()

WebRequest::getAllHeaders ( )

Get an array containing all request headers.

Returns
Array mapping header name to its value

Reimplemented in DerivativeRequest.

Definition at line 917 of file WebRequest.php.

References $headers, and initHeaders().

◆ getArray()

WebRequest::getArray (   $name,
  $default = null 
)

Fetch an array from the input or return $default if it's not set.

If source was scalar, will return an array with a single element. If no source and no default, returns NULL.

Parameters
$nameString
array$defaultoptional default (or NULL)
Returns
Array

Definition at line 424 of file WebRequest.php.

References $name, array(), data, and getGPCVal().

Referenced by getIntArray().

◆ getBool()

WebRequest::getBool (   $name,
  $default = false 
)

Fetch a boolean value from the input or return $default if not set.

Guaranteed to return true or false, with normal PHP semantics for boolean interpretation of strings.

Parameters
$nameString
$defaultBoolean
Returns
Boolean

Definition at line 502 of file WebRequest.php.

References $name, and getVal().

Referenced by FormOptions\fetchValuesFromRequest(), and getFuzzyBool().

◆ getCheck()

WebRequest::getCheck (   $name)

Return true if the named value is set in the input, whatever that value is (even "0").

Return false if the named value is not set. Example use is checking for the presence of check boxes in forms.

Parameters
$nameString
Returns
Boolean

Definition at line 527 of file WebRequest.php.

References $name, and getVal().

◆ getCookie()

WebRequest::getCookie (   $key,
  $prefix = null,
  $default = null 
)

Get a cookie from the $_COOKIE jar.

Parameters
string$keythe name of the cookie
string$prefixa prefix to use for the cookie name, if not $wgCookiePrefix
$defaultMixed: what to return if the value isn't found
Returns
Mixed: cookie value or $default if the cookie not set

Reimplemented in DerivativeRequest, and FauxRequest.

Definition at line 678 of file WebRequest.php.

References $wgCookiePrefix, getGPCVal(), and global.

◆ getFileName()

WebRequest::getFileName (   $key)

Return the original filename of the uploaded file, as reported by the submitting user agent.

HTML-style character entities are interpreted and normalized to Unicode normalization form C, in part to deal with weird input from Safari with non-ASCII filenames.

Other than this the name is not verified for being a safe filename.

Parameters
$keyString:
Returns
string or NULL if no such file.

Definition at line 857 of file WebRequest.php.

References $file.

◆ getFileTempname()

WebRequest::getFileTempname (   $key)

Return the path to the temporary file where PHP has stored the upload.

Parameters
$keyString:
Returns
string or NULL if no such file.

Definition at line 830 of file WebRequest.php.

References $file.

◆ getFloat()

WebRequest::getFloat (   $name,
  $default = 0 
)

Fetch a floating point value from the input or return $default if not set.

Guaranteed to return a float; non-numeric input will typically return 0.

Since
1.23
Parameters
$nameString
$defaultFloat
Returns
Float

Definition at line 489 of file WebRequest.php.

References $name, and getVal().

Referenced by FormOptions\fetchValuesFromRequest().

◆ getFullRequestURL()

WebRequest::getFullRequestURL ( )

Return the request URI with the canonical service and hostname, path, and query string.

This will be suitable for use as an absolute link in HTML or other output.

If $wgServer is protocol-relative, this will return a fully qualified URL with the protocol that was used for this request.

Returns
String

Definition at line 738 of file WebRequest.php.

References getRequestURL(), PROTO_CURRENT, and wfExpandUrl().

Referenced by checkUrlExtension().

◆ getFuzzyBool()

WebRequest::getFuzzyBool (   $name,
  $default = false 
)

Fetch a boolean value from the input or return $default if not set.

Unlike getBool, the string "false" will result in boolean false, which is useful when interpreting information sent from JavaScript.

Parameters
$nameString
$defaultBoolean
Returns
Boolean

Definition at line 515 of file WebRequest.php.

References $name, getBool(), and getVal().

◆ getGPCVal()

WebRequest::getGPCVal (   $arr,
  $name,
  $default 
)
private

Fetch a value from the given array or return $default if it's not set.

Parameters
$arrArray
$nameString
$defaultMixed
Returns
mixed

Definition at line 343 of file WebRequest.php.

References $data, $name, $wgContLang, global, and normalizeUnicode().

Referenced by getArray(), getCookie(), getVal(), and getValues().

◆ getHeader()

WebRequest::getHeader (   $name)

Get a request header, or false if it isn't set.

Parameters
string$namecase-insensitive header name
Returns
string|bool False on failure

Reimplemented in DerivativeRequest, and FauxRequest.

Definition at line 928 of file WebRequest.php.

References $name, headers, and initHeaders().

◆ getInt()

WebRequest::getInt (   $name,
  $default = 0 
)

Fetch an integer value from the input or return $default if not set.

Guaranteed to return an integer; non-numeric input will typically return 0.

Parameters
$nameString
$defaultInteger
Returns
Integer

Definition at line 460 of file WebRequest.php.

References $name, and getVal().

Referenced by FormOptions\fetchValuesFromRequest(), and getLimitOffset().

◆ getIntArray()

WebRequest::getIntArray (   $name,
  $default = null 
)

Fetch an array of integers, or return $default if it's not set.

If source was scalar, will return an array with a single element. If no source and no default, returns NULL. If an array is returned, contents are guaranteed to be integers.

Parameters
$nameString
array$defaultoption default (or NULL)
Returns
Array of ints

Definition at line 443 of file WebRequest.php.

References $name, and getArray().

◆ getIntOrNull()

WebRequest::getIntOrNull (   $name)

Fetch an integer value from the input or return null if empty.

Guaranteed to return an integer or null; non-numeric input will typically return null.

Parameters
$nameString
Returns
Integer

Definition at line 472 of file WebRequest.php.

References $name, and getVal().

Referenced by FormOptions\fetchValuesFromRequest().

◆ getIP()

WebRequest::getIP ( )

Work out the IP address based on various globals For trusted proxies, use the XFF client IP (first of the chain)

Since
1.19
Exceptions
MWException
Returns
string

Reimplemented in DerivativeRequest.

Definition at line 1102 of file WebRequest.php.

Referenced by FileCacheBase\incrMissesRecent().

◆ getLimitOffset()

WebRequest::getLimitOffset (   $deflimit = 50,
  $optionname = 'rclimit' 
)

Check for limit and offset parameters on the input, and return sensible defaults if not given.

The limit must be positive and is capped at 5000. Offset must be positive but is not capped.

Parameters
$deflimitInteger: limit to use if no input and the user hasn't set the option.
string$optionnameto specify an option other than rclimit to pull from.
Returns
array first element is limit, second is offset

Definition at line 799 of file WebRequest.php.

References $limit, $wgUser, array(), getInt(), global, and some.

◆ getMethod()

WebRequest::getMethod ( )

Get the HTTP method used for this request.

Returns
String

Reimplemented in FauxRequest.

Definition at line 638 of file WebRequest.php.

Referenced by wasPosted().

◆ getPathInfo()

static WebRequest::getPathInfo (   $want = 'all')
static

Extract relevant query arguments from the http request uri's path to be merged with the normal php provided query arguments.

Tries to use the REQUEST_URI data if available and parses it according to the wiki's configuration looking for any known pattern.

If the REQUEST_URI is not provided we'll fall back on the PATH_INFO provided by the server if any and use that to set a 'title' parameter.

Parameters
string$wantIf this is not 'all', then the function will return an empty array if it determines that the URL is inside a rewrite path.
Returns
Array: Any query arguments found in path matches.

Definition at line 82 of file WebRequest.php.

References $matches, $path, $wgActionPaths, $wgArticlePath, $wgContLang, PathRouter\add(), array(), global, wfRestoreWarnings(), wfRunHooks(), and wfSuppressWarnings().

Referenced by interpolateTitle(), and wfThumbHandle404().

◆ getProtocol()

WebRequest::getProtocol ( )

Get the current URL protocol (http or https)

Returns
string

Reimplemented in DerivativeRequest, and FauxRequest.

Definition at line 216 of file WebRequest.php.

References $protocol, and detectProtocol().

◆ getQueryValues()

WebRequest::getQueryValues ( )

Get the values passed in the query string.

No transformation is performed on the values.

Returns
Array

Reimplemented in FauxRequest.

Definition at line 591 of file WebRequest.php.

Referenced by appendQueryArray().

◆ getRawInput()

WebRequest::getRawInput ( )

Return the raw request body, with no processing.

Cached since some methods disallow reading the stream more than once. As stated in the php docs, this does not work with enctype="multipart/form-data".

Returns
String

Reimplemented in FauxRequest.

Definition at line 625 of file WebRequest.php.

Referenced by getRawPostString().

◆ getRawIP()

WebRequest::getRawIP ( )
protected

Fetch the raw IP from the request.

Since
1.19
Exceptions
MWException
Returns
String

Reimplemented in FauxRequest.

Definition at line 1079 of file WebRequest.php.

◆ getRawPostString()

WebRequest::getRawPostString ( )

Return the contents of the POST with no decoding.

Use when you need to know exactly what was sent, e.g. for an OAuth signature over the elements.

Returns
String

Reimplemented in FauxRequest.

Definition at line 611 of file WebRequest.php.

References getRawInput(), and wasPosted().

◆ getRawQueryString()

WebRequest::getRawQueryString ( )

Return the contents of the Query with no decoding.

Use when you need to know exactly what was sent, e.g. for an OAuth signature over the elements.

Returns
String

Reimplemented in FauxRequest.

Definition at line 601 of file WebRequest.php.

◆ getRequestURL()

WebRequest::getRequestURL ( )

Return the path and query string portion of the request URI.

This will be suitable for use as a relative link in HTML output.

Exceptions
MWException
Returns
String

Reimplemented in FauxRequest.

Definition at line 693 of file WebRequest.php.

References $hash.

Referenced by getFullRequestURL().

◆ getSessionData()

WebRequest::getSessionData (   $key)

Get data from $_SESSION.

Parameters
string$keyname of key in $_SESSION
Returns
Mixed

Reimplemented in DerivativeRequest, and FauxRequest.

Definition at line 944 of file WebRequest.php.

◆ getText()

WebRequest::getText (   $name,
  $default = '' 
)

Fetch a text string from the given array or return $default if it's not set.

Carriage returns are stripped from the text, and with some language modules there is an input transliteration applied. This should generally be used for form "<textarea>" and "<input>" fields. Used for user-supplied freeform text input (for which input transformations may be required - e.g. Esperanto x-coding).

Parameters
$nameString
string$defaultoptional
Returns
String

Reimplemented in FauxRequest.

Definition at line 545 of file WebRequest.php.

References $name, $wgContLang, getVal(), and global.

Referenced by FormOptions\fetchValuesFromRequest(), and LoginForm\load().

◆ getUpload()

WebRequest::getUpload (   $key)

Return a WebRequestUpload object corresponding to the key.

Parameters
$keystring
Returns
WebRequestUpload

Definition at line 868 of file WebRequest.php.

◆ getUploadError()

WebRequest::getUploadError (   $key)

Return the upload error or 0.

Parameters
$keyString:
Returns
integer

Definition at line 841 of file WebRequest.php.

References $file.

◆ getVal()

WebRequest::getVal (   $name,
  $default = null 
)

Fetch a scalar from the input or return $default if it's not set.

Returns a string. Arrays are discarded. Useful for non-freeform text inputs (e.g. predefined internal text keys selected by a drop-down menu). For freeform input, see getText().

Parameters
$nameString
string$defaultoptional default (or NULL)
Returns
String

Definition at line 374 of file WebRequest.php.

References $name, data, and getGPCVal().

Referenced by ResourceLoaderContext\__construct(), getBool(), getCheck(), getFloat(), getFuzzyBool(), getInt(), getIntOrNull(), RequestContext\getLanguage(), and getText().

◆ getValueNames()

WebRequest::getValueNames (   $exclude = array())

Returns the names of all input values excluding those in $exclude.

Parameters
$excludeArray
Returns
array

Definition at line 581 of file WebRequest.php.

References $exclude, and getValues().

◆ getValues()

WebRequest::getValues ( )

Extracts the given named values into an array.

If no arguments are given, returns all input values. No transformation is performed on the values.

Returns
array

Reimplemented in FauxRequest.

Definition at line 559 of file WebRequest.php.

References $name, $value, array(), as, data, and getGPCVal().

Referenced by getValueNames().

◆ initHeaders()

WebRequest::initHeaders ( )
private

Initialise the header list.

Definition at line 890 of file WebRequest.php.

References $name, $value, as, and headers.

Referenced by getAllHeaders(), and getHeader().

◆ interpolateTitle()

WebRequest::interpolateTitle ( )

Check for title, action, and/or variant data in the URL and interpolate it into the GET variables.

This should only be run after $wgContLang is available, as we may need the list of language variants to determine available variant URLs.

Definition at line 230 of file WebRequest.php.

References $matches, as, data, and getPathInfo().

◆ normalizeUnicode()

WebRequest::normalizeUnicode (   $data)

Recursively normalizes UTF-8 strings in the given array.

Parameters
$datastring|array
Returns
array|string cleaned-up version of the given
Access:\n private

Definition at line 323 of file WebRequest.php.

References $data, $wgContLang, as, UtfNormal\cleanUp(), and global.

Referenced by getGPCVal().

◆ response()

WebRequest::response ( )

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

Returns
WebResponse

Definition at line 878 of file WebRequest.php.

References $response.

◆ setIP()

WebRequest::setIP (   $ip)
Parameters
string$ip
Returns
void
Since
1.21

Definition at line 1168 of file WebRequest.php.

Referenced by RequestContext\importScopedSession().

◆ setSessionData()

WebRequest::setSessionData (   $key,
  $data 
)

Set session data.

Parameters
string$keyname of key in $_SESSION
$dataMixed

Reimplemented in DerivativeRequest, and FauxRequest.

Definition at line 957 of file WebRequest.php.

References $data.

◆ setVal()

WebRequest::setVal (   $key,
  $value 
)

Set an arbitrary value into our get/post data.

Parameters
string$keykey name to use
$valueMixed: value to set
Returns
Mixed: old value if one was present, null otherwise

Definition at line 393 of file WebRequest.php.

References $ret, $value, and data.

◆ unsetVal()

WebRequest::unsetVal (   $key)

Unset an arbitrary value from our get/post data.

Parameters
string$keykey name to use
Returns
Mixed: old value if one was present, null otherwise

Definition at line 405 of file WebRequest.php.

References $ret, and data.

◆ wasPosted()

WebRequest::wasPosted ( )

Returns true if the present request was reached by a POST operation, false otherwise (GET, HEAD, or command-line).

Note that values retrieved by the object may come from the GET URL etc even on a POST request.

Returns
Boolean

Reimplemented in FauxRequest.

Definition at line 651 of file WebRequest.php.

References getMethod().

Referenced by checkUrlExtension(), and getRawPostString().

Member Data Documentation

◆ $data

WebRequest::$data
protected

◆ $headers

WebRequest::$headers = array()

Definition at line 39 of file WebRequest.php.

Referenced by getAllHeaders().

◆ $ip

String WebRequest::$ip
private

Cached client IP address.

Definition at line 49 of file WebRequest.php.

◆ $protocol

string WebRequest::$protocol
protected

Cached URL protocol.

Definition at line 54 of file WebRequest.php.

Referenced by getProtocol(), and FauxRequest\setHeader().

◆ $response

WebResponse WebRequest::$response
private

Lazy-init response object.

Definition at line 44 of file WebRequest.php.

Referenced by response().


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