MediaWiki master
|
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping illegal input characters and normalizing Unicode sequences. More...
Inherited by MediaWiki\Request\FauxRequest.
Public Member Functions | |
__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 the input or return $default if it's not set. | |
getBool ( $name, $default=false) | |
Fetch a boolean value from the input or return $default if not set. | |
getCheck ( $name) | |
Return true if the named value is set in the input, whatever that value is (even "0"). | |
getCookie ( $key, $prefix=null, $default=null) | |
Get a cookie from the $_COOKIE jar. | |
getCrossSiteCookie ( $key, $prefix='', $default=null) | |
Get a cookie set with SameSite=None possibly with a legacy fallback cookie. | |
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 the input 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 the input 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 the input or return $default if not set. | |
getIntArray ( $name, $default=null) | |
Fetch an array of integers, or return $default if it's not set. | |
getIntOrNull ( $name) | |
Fetch an integer value from the input 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. | |
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 () | |
Get the values passed in the query string and the path router parameters. | |
getQueryValuesOnly () | |
Get the values passed in the query string only, not including the path router parameters. | |
getRawInput () | |
Return the raw request body, with no processing. | |
getRawPostString () | |
Return the contents of the POST with no decoding. | |
getRawQueryString () | |
Return the contents of the Query with no decoding. | |
getRawVal ( $name, $default=null) | |
Fetch a string WITHOUT any Unicode or line break normalization. | |
getRequestURL () | |
Return the path and query string portion of the request URI. | |
getSession () | |
Return the session for this request. | |
getSessionData ( $key) | |
Get data from the session. | |
getSessionId () | |
Get the session id for this request, if any. | |
getText ( $name, $default='') | |
Fetch a text string and return it in normalized form. | |
getUpload ( $key) | |
Return a MediaWiki\Request\WebRequestUpload object corresponding to the key. | |
getUploadError ( $key) | |
Return the upload error or 0. | |
getVal ( $name, $default=null) | |
Fetch a text string and partially normalize it. | |
getValueNames ( $exclude=[]) | |
Returns the names of all input values excluding those in $exclude. | |
getValues (... $names) | |
Extracts the (given) named values 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. | |
response () | |
Return a handle to WebResponse style object, for setting cookies, headers and other stuff, for Request being worked on. | |
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. | |
wasPosted () | |
Returns true if the present request was reached by a POST operation, false otherwise (GET, HEAD, or command-line). | |
Static Public Member Functions | |
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 ( $basePath) |
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 | |
const | GETHEADER_LIST = 1 |
Flag to make WebRequest::getHeader return an array of values. | |
Protected Member Functions | |
getRawIP () | |
Fetch the raw IP from the request. | |
initHeaders () | |
Initialise the header list. | |
Static Protected Member Functions | |
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. | |
Protected Attributes | |
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. | |
SessionId null | $sessionId = null |
Session ID to use for this request. | |
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping illegal input characters and normalizing Unicode sequences.
Definition at line 50 of file WebRequest.php.
MediaWiki\Request\WebRequest::__construct | ( | ) |
Definition at line 122 of file WebRequest.php.
MediaWiki\Request\WebRequest::appendQueryArray | ( | $array | ) |
Appends or replaces value of query variables.
array | $array | Array of values to replace/add to query |
Definition at line 1017 of file WebRequest.php.
References wfArrayToCgi().
MediaWiki\Request\WebRequest::appendQueryValue | ( | $key, | |
$value | |||
) |
|
static |
Converts ::1 (IPv6 loopback address) to 127.0.0.1 (IPv4 loopback address); assists in matching trusted proxies.
string | $ip |
Definition at line 1364 of file WebRequest.php.
|
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().
Definition at line 309 of file WebRequest.php.
Referenced by MediaWiki\Request\WebRequest\detectServer(), and MediaWiki\Request\WebRequest\getProtocol().
|
static |
Work out an appropriate URL prefix containing scheme and host, based on information detected from $_SERVER.
bool | null | $assumeProxiesUseDefaultProtocolPorts | When the wiki is running behind a proxy and this is set to true, assumes that the proxy exposes the wiki on the standard ports (443 for https and 80 for http). Added in 1.38. Calls without this argument are supported for backwards compatibility but deprecated. |
Definition at line 263 of file WebRequest.php.
References MediaWiki\Request\WebRequest\detectProtocol().
|
static |
URL rewriting function; tries to extract page title and, optionally, one other fixed parameter value from a URL path.
string | $path | The URL path given from the client |
array | $bases | One or more URLs, optionally with $1 at the end |
string | false | $key | If provided, the matching key in $bases will be passed on as the value of this URL parameter |
Definition at line 394 of file WebRequest.php.
MediaWiki\Request\WebRequest::getAcceptLang | ( | ) |
Parse the Accept-Language header sent by the client into an array.
This logic is aligned with RFC 7231 section 5 (previously RFC 2616 section 14), at https://tools.ietf.org/html/rfc7231#section-5.3.5.
Earlier languages in the list are preferred as per the RFC 23282 extension to HTTP/1.1, at https://tools.ietf.org/html/rfc3282.
Reimplemented in MediaWiki\Request\DerivativeRequest.
Definition at line 1202 of file WebRequest.php.
References $matches.
MediaWiki\Request\WebRequest::getAllHeaders | ( | ) |
Get an array containing all request headers.
Reimplemented in MediaWiki\Request\DerivativeRequest.
Definition at line 1137 of file WebRequest.php.
MediaWiki\Request\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.
string | $name | |
array | null | $default | Optional default (or null) |
Definition at line 577 of file WebRequest.php.
Referenced by MediaWiki\Html\FormOptions\fetchValuesFromRequest(), and MediaWiki\Request\WebRequest\getIntArray().
MediaWiki\Request\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.
string | $name | |
bool | $default |
Definition at line 656 of file WebRequest.php.
Referenced by MediaWiki\Html\FormOptions\fetchValuesFromRequest(), and HistoryAction\onView().
MediaWiki\Request\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.
string | $name |
Definition at line 687 of file WebRequest.php.
Referenced by HTMLFormField\isSubmitAttempt(), and HistoryAction\onView().
MediaWiki\Request\WebRequest::getCookie | ( | $key, | |
$prefix = null , |
|||
$default = null |
|||
) |
Get a cookie from the $_COOKIE jar.
string | $key | The name of the cookie |
string | null | $prefix | A prefix to use for the cookie name, if not $wgCookiePrefix |
mixed | null | $default | What to return if the value isn't found |
Reimplemented in MediaWiki\Request\DerivativeRequest, and MediaWiki\Request\FauxRequest.
Definition at line 878 of file WebRequest.php.
References $wgCookiePrefix.
Referenced by MediaWiki\Session\ImmutableSessionProviderWithCookie\getSessionIdFromCookie().
MediaWiki\Request\WebRequest::getCrossSiteCookie | ( | $key, | |
$prefix = '' , |
|||
$default = null |
|||
) |
Get a cookie set with SameSite=None possibly with a legacy fallback cookie.
string | $key | The name of the cookie |
string | $prefix | A prefix to use, empty by default |
mixed | null | $default | What to return if the value isn't found |
Definition at line 901 of file WebRequest.php.
References $wgUseSameSiteLegacyCookies.
MediaWiki\Request\WebRequest::getElapsedTime | ( | ) |
Get the number of seconds to have elapsed since request start, in fractional seconds, with microsecond resolution.
Reimplemented in MediaWiki\Request\DerivativeRequest.
Definition at line 326 of file WebRequest.php.
References MediaWiki\Request\WebRequest\$requestTime.
MediaWiki\Request\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.
string | $key |
Definition at line 1091 of file WebRequest.php.
MediaWiki\Request\WebRequest::getFileTempname | ( | $key | ) |
Return the path to the temporary file where PHP has stored the upload.
string | $key |
Definition at line 1066 of file WebRequest.php.
MediaWiki\Request\WebRequest::getFloat | ( | $name, | |
$default = 0.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.
string | $name | |
float | $default |
Definition at line 642 of file WebRequest.php.
Referenced by MediaWiki\Html\FormOptions\fetchValuesFromRequest().
MediaWiki\Request\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 of this request object.
Definition at line 991 of file WebRequest.php.
References PROTO_HTTP, PROTO_HTTPS, and wfGetServerUrl().
MediaWiki\Request\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.
string | $name | |
bool | $default |
Definition at line 670 of file WebRequest.php.
Referenced by MediaWiki\ResourceLoader\Context\__construct().
|
static |
Return the path and query string portion of the main request URI.
This will be suitable for use as a relative link in HTML output.
MWException |
Definition at line 927 of file WebRequest.php.
Referenced by MediaWiki\Request\HeaderCallback\callback(), and MediaWiki\Request\WebRequest\getRequestPathSuffix().
MediaWiki\Request\WebRequest::getHeader | ( | $name, | |
$flags = 0 |
|||
) |
Get a request header, or false if it isn't set.
string | $name | Case-insensitive header name |
int | $flags | Bitwise combination of: WebRequest::GETHEADER_LIST Treat the header as a comma-separated list of values, as described in RFC 2616 § 4.2. (since 1.26). |
Reimplemented in MediaWiki\Request\DerivativeRequest.
Definition at line 1155 of file WebRequest.php.
Referenced by PageDataRequestHandler\httpContentNegotiation().
MediaWiki\Request\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.
string | $name | |
int | $default |
Definition at line 614 of file WebRequest.php.
Referenced by MediaWiki\Html\FormOptions\fetchValuesFromRequest(), and PageDataRequestHandler\handleRequest().
MediaWiki\Request\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.
string | $name | |
array | null | $default | Option default (or null) |
Definition at line 597 of file WebRequest.php.
References MediaWiki\Request\WebRequest\getArray().
MediaWiki\Request\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.
string | $name |
Definition at line 627 of file WebRequest.php.
Referenced by MediaWiki\Html\FormOptions\fetchValuesFromRequest(), and ImagePage\openShowImage().
MediaWiki\Request\WebRequest::getIP | ( | ) |
Work out the IP address based on various globals For trusted proxies, use the XFF client IP (first of the chain)
Reimplemented in MediaWiki\Request\DerivativeRequest.
Definition at line 1274 of file WebRequest.php.
Referenced by MWRestrictions\check(), MediaWiki\Block\BlockManager\getCreateAccountBlock(), FileCacheBase\incrMissesRecent(), and MediaWiki\User\BotPassword\login().
MediaWiki\Request\WebRequest::getLimitOffsetForUser | ( | UserIdentity | $user, |
$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.
UserIdentity | $user | UserIdentity to get option for |
int | $deflimit | Limit to use if no input and the user hasn't set the option. |
string | $optionname | To specify an option other than rclimit to pull from. |
Definition at line 1035 of file WebRequest.php.
MediaWiki\Request\WebRequest::getMethod | ( | ) |
Get the HTTP method used for this request.
Reimplemented in MediaWiki\Request\FauxRequest.
Definition at line 809 of file WebRequest.php.
|
staticprotected |
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.
This internal method handles many odd cases and is tailored specifically for used by WebRequest::interpolateTitle, for index.php requests. Consider using WebRequest::getRequestPathSuffix for other path-related use cases.
string | $want | If this is not 'all', then the function will return an empty array if it determines that the URL is inside a rewrite path. |
FatalError | If invalid routes are configured (T48998) |
Definition at line 152 of file WebRequest.php.
References $matches, $path, $wgActionPaths, $wgArticlePath, $wgScript, $wgUsePathInfo, $wgVariantArticlePath, MediaWiki\Request\PathRouter\add(), MediaWiki\Request\PathRouter\getActionPaths(), and MediaWiki\MediaWikiServices\getInstance().
Referenced by MediaWiki\Request\WebRequest\interpolateTitle().
MediaWiki\Request\WebRequest::getPostValues | ( | ) |
Get the values passed via POST.
No transformation is performed on the values.
¶m[]=…
parameter Reimplemented in MediaWiki\Request\FauxRequest.
Definition at line 760 of file WebRequest.php.
MediaWiki\Request\WebRequest::getProtocol | ( | ) |
Get the current URL protocol (http or https)
Reimplemented in MediaWiki\Request\DerivativeRequest, and MediaWiki\Request\FauxRequest.
Definition at line 365 of file WebRequest.php.
References MediaWiki\Request\WebRequest\$protocol, and MediaWiki\Request\WebRequest\detectProtocol().
MediaWiki\Request\WebRequest::getQueryValues | ( | ) |
Get the values passed in the query string and the path router parameters.
No transformation is performed on the values.
¶m[]=…
parameter Reimplemented in MediaWiki\Request\FauxRequest.
Definition at line 735 of file WebRequest.php.
MediaWiki\Request\WebRequest::getQueryValuesOnly | ( | ) |
Get the values passed in the query string 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.
¶m[]=…
parameter Definition at line 748 of file WebRequest.php.
Referenced by ImagePage\openShowImage().
MediaWiki\Request\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".
Reimplemented in MediaWiki\Request\FauxRequest.
Definition at line 798 of file WebRequest.php.
|
protected |
Fetch the raw IP from the request.
Reimplemented in MediaWiki\Request\FauxRequest.
Definition at line 1255 of file WebRequest.php.
MediaWiki\Request\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.
Reimplemented in MediaWiki\Request\FauxRequest.
Definition at line 783 of file WebRequest.php.
MediaWiki\Request\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.
Reimplemented in MediaWiki\Request\FauxRequest.
Definition at line 772 of file WebRequest.php.
MediaWiki\Request\WebRequest::getRawVal | ( | $name, | |
$default = null |
|||
) |
Fetch a string WITHOUT any Unicode or line break normalization.
This is a fast alternative for values that are known to be simple, e.g. pure ASCII. When reading user input, use {
Array values are discarded for security reasons. Use {
string | $name | |
string | null | $default |
Definition at line 479 of file WebRequest.php.
Referenced by MediaWiki\ResourceLoader\Context\__construct(), and HistoryAction\onView().
|
static |
Get the current request ID.
This is usually based on the X-Request-Id
header, or the UNIQUE_ID
environment variable, falling back to (process cached) randomly-generated string.
Definition at line 340 of file WebRequest.php.
|
static |
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.
If the request URL does not match, false is returned.
string | $basePath | The base URL path. Trailing slashes will be stripped. |
Definition at line 237 of file WebRequest.php.
References MediaWiki\Request\WebRequest\getGlobalRequestURL().
MediaWiki\Request\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.
MWException |
Reimplemented in MediaWiki\Request\FauxRequest.
Definition at line 976 of file WebRequest.php.
MediaWiki\Request\WebRequest::getSession | ( | ) |
Return the session for this request.
This might unpersist an existing session if it was invalid.
Reimplemented in MediaWiki\Request\DerivativeRequest.
Definition at line 836 of file WebRequest.php.
Referenced by MediaWiki\Request\FauxRequest\getSessionArray().
MediaWiki\Request\WebRequest::getSessionData | ( | $key | ) |
Get data from the session.
string | $key | Name of key in the session |
Reimplemented in MediaWiki\Request\DerivativeRequest.
Definition at line 1175 of file WebRequest.php.
MediaWiki\Request\WebRequest::getSessionId | ( | ) |
Get the session id for this request, if any.
Definition at line 865 of file WebRequest.php.
MediaWiki\Request\WebRequest::getText | ( | $name, | |
$default = '' |
|||
) |
Fetch a text string and return it in normalized form.
This normalizes Unicode sequences (via {
This should be used for all user input and form fields that are expected to contain non-ASCII characters, especially if the value will be stored or compared against stored values. Without normalization, logically identically values might not match when they are typed on different OS' or keyboards.
Array values are discarded for security reasons. Use {
string | $name | |
string | $default |
Reimplemented in MediaWiki\Request\FauxRequest.
Definition at line 533 of file WebRequest.php.
References MediaWiki\Request\WebRequest\getVal().
Referenced by PageDataRequestHandler\canHandleRequest(), MediaWiki\Html\FormOptions\fetchValuesFromRequest(), and PageDataRequestHandler\handleRequest().
MediaWiki\Request\WebRequest::getUpload | ( | $key | ) |
Return a MediaWiki\Request\WebRequestUpload object corresponding to the key.
string | $key |
Reimplemented in MediaWiki\Request\DerivativeRequest, and MediaWiki\Request\FauxRequest.
Definition at line 1101 of file WebRequest.php.
MediaWiki\Request\WebRequest::getUploadError | ( | $key | ) |
Return the upload error or 0.
string | $key |
Definition at line 1076 of file WebRequest.php.
MediaWiki\Request\WebRequest::getVal | ( | $name, | |
$default = null |
|||
) |
Fetch a text string and partially normalize it.
Use of this method is discouraged. It doesn't normalize line breaks and defaults to null instead of the empty string. Instead:
string | $name | |
string | null | $default |
Definition at line 507 of file WebRequest.php.
Referenced by MediaWiki\Request\FauxRequest\getText(), MediaWiki\Request\WebRequest\getText(), and HistoryAction\onView().
MediaWiki\Request\WebRequest::getValueNames | ( | $exclude = [] | ) |
Returns the names of all input values excluding those in $exclude.
array | $exclude |
Definition at line 723 of file WebRequest.php.
MediaWiki\Request\WebRequest::getValues | ( | $names | ) |
Extracts the (given) named values into an array.
No transformation is performed on the values.
string | ...$names If no arguments are given, returns all input values |
Definition at line 701 of file WebRequest.php.
MediaWiki\Request\WebRequest::hasSafeMethod | ( | ) |
Check if this request uses a "safe" HTTP method.
Safe methods are verbs (e.g. GET/HEAD/OPTIONS) used for obtaining content. Such requests are not expected to mutate content, especially in ways attributable to the client. Verbs like POST and PUT are typical of non-safe requests which often change content.
Definition at line 1393 of file WebRequest.php.
|
protected |
Initialise the header list.
Reimplemented in MediaWiki\Request\FauxRequest.
Definition at line 1123 of file WebRequest.php.
MediaWiki\Request\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 the content language is available, as we may need the list of language variants to determine available variant URLs.
Definition at line 377 of file WebRequest.php.
References $matches, and MediaWiki\Request\WebRequest\getPathInfo().
MediaWiki\Request\WebRequest::isSafeRequest | ( | ) |
Whether this request should be identified as being "safe".
This means that the client is not requesting any state changes and that database writes are not inherently required. Ideally, no visible updates would happen at all. If they must, then they should not be publicly attributed to the end user.
In more detail:
Definition at line 1421 of file WebRequest.php.
References wfDeprecated().
MediaWiki\Request\WebRequest::markAsSafeRequest | ( | ) |
Mark this request as identified as being nullipotent even if it is a POST request.
POST requests are often used due to the need for a client payload, even if the request is otherwise equivalent to a "safe method" request.
Definition at line 1442 of file WebRequest.php.
References wfDeprecated().
MediaWiki\Request\WebRequest::matchURLForCDN | ( | array | $cdnUrls | ) |
Determine if the request URL matches one of a given set of canonical CDN URLs.
MediaWiki uses this to determine whether to set a long 'Cache-Control: s-maxage=' header on the response. {
string[] | $cdnUrls | URLs to match against |
Definition at line 1458 of file WebRequest.php.
References PROTO_INTERNAL.
MediaWiki\Request\WebRequest::normalizeUnicode | ( | $data | ) |
Recursively normalizes UTF-8 strings in the given array.
string | array | $data |
Definition at line 419 of file WebRequest.php.
References MediaWiki\Request\WebRequest\$data, MediaWiki\MediaWikiServices\getInstance(), and MediaWiki\Request\WebRequest\normalizeUnicode().
Referenced by MediaWiki\Request\WebRequest\normalizeUnicode().
|
static |
Override the unique request ID.
This is for sub-requests, such as jobs, that wish to use the same id but are not part of the same execution context.
string | null | $newId |
Definition at line 352 of file WebRequest.php.
MediaWiki\Request\WebRequest::response | ( | ) |
Return a handle to WebResponse style object, for setting cookies, headers and other stuff, for Request being worked on.
Definition at line 1111 of file WebRequest.php.
Referenced by ImagePage\openShowImage(), MediaWiki\Session\CookieSessionProvider\persistSession(), MediaWiki\Session\ImmutableSessionProviderWithCookie\persistSession(), MediaWiki\Session\CookieSessionProvider\setForceHTTPSCookie(), MediaWiki\Session\CookieSessionProvider\setLoggedOutCookie(), MediaWiki\Session\CookieSessionProvider\unpersistSession(), and MediaWiki\Session\ImmutableSessionProviderWithCookie\unpersistSession().
MediaWiki\Request\WebRequest::setIP | ( | $ip | ) |
string | $ip |
Reimplemented in MediaWiki\Request\DerivativeRequest.
Definition at line 1377 of file WebRequest.php.
MediaWiki\Request\WebRequest::setSessionData | ( | $key, | |
$data | |||
) |
string | $key | Name of key in the session |
mixed | $data |
Reimplemented in MediaWiki\Request\DerivativeRequest.
Definition at line 1184 of file WebRequest.php.
MediaWiki\Request\WebRequest::setSessionId | ( | SessionId | $sessionId | ) |
Set the session for this request.
SessionId | $sessionId |
Definition at line 855 of file WebRequest.php.
Referenced by MediaWiki\Session\SessionManager\getSessionFromInfo(), and MediaWiki\Session\Session\sessionWithRequest().
MediaWiki\Request\WebRequest::setVal | ( | $key, | |
$value | |||
) |
Set an arbitrary value into our get/post data.
string | $key | Key name to use |
mixed | $value | Value to set |
Definition at line 545 of file WebRequest.php.
MediaWiki\Request\WebRequest::unsetVal | ( | $key | ) |
Unset an arbitrary value from our get/post data.
string | $key | Key name to use |
Definition at line 557 of file WebRequest.php.
MediaWiki\Request\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.
Reimplemented in MediaWiki\Request\FauxRequest.
Definition at line 822 of file WebRequest.php.
Referenced by HTMLFormField\isSubmitAttempt().
|
protected |
The parameters from $_GET, $_POST and the path router.
Definition at line 55 of file WebRequest.php.
Referenced by MediaWiki\Request\FauxRequest\__construct(), MediaWiki\Request\DerivativeRequest\__construct(), MediaWiki\Request\FauxRequest\getQueryValues(), MediaWiki\Request\WebRequest\normalizeUnicode(), MediaWiki\Request\FauxRequest\setUpload(), and MediaWiki\Request\FauxRequest\setUploadData().
|
protected |
Lazy-initialized request headers indexed by upper-case header name.
Definition at line 74 of file WebRequest.php.
Referenced by MediaWiki\Request\FauxRequest\setHeaders().
|
protected |
Whether this HTTP request is "safe" (even if it is an HTTP post)
Definition at line 117 of file WebRequest.php.
|
protected |
Cached URL protocol.
Definition at line 104 of file WebRequest.php.
Referenced by MediaWiki\Request\FauxRequest\__construct(), MediaWiki\Request\FauxRequest\getProtocol(), and MediaWiki\Request\WebRequest\getProtocol().
|
protected |
The parameters from $_GET.
The parameters from the path router are added by interpolateTitle() during Setup.php.
Definition at line 62 of file WebRequest.php.
|
protected |
The parameters from $_GET only.
Definition at line 68 of file WebRequest.php.
|
protected |
The timestamp of the start of the request, with microsecond precision.
Definition at line 98 of file WebRequest.php.
Referenced by MediaWiki\Request\WebRequest\getElapsedTime().
|
protected |
Session ID to use for this request.
We can't save the session directly due to reference cycles not working too well (slow GC).
TODO: Investigate whether this GC slowness concern (added in a73c5b7395 with regard to PHP 5.6) still applies in PHP 7.2+.
Definition at line 114 of file WebRequest.php.
const MediaWiki\Request\WebRequest::GETHEADER_LIST = 1 |
Flag to make WebRequest::getHeader return an array of values.
Definition at line 80 of file WebRequest.php.