Added WebRequest::getMethod() to get the HTTP method of the request.
This is to replace the usage of $_SERVER['REQUEST_METHOD']. Change-Id: I45084254c5452b00b0665df78628cfd214e39cab
This commit is contained in:
parent
03cf97938b
commit
53b3c82fd7
3 changed files with 16 additions and 3 deletions
|
|
@ -449,7 +449,7 @@ if ( $wgCommandLineMode ) {
|
|||
# Can't stub this one, it sets up $_GET and $_REQUEST in its constructor
|
||||
$wgRequest = new WebRequest;
|
||||
|
||||
$debug = "\n\nStart request {$_SERVER['REQUEST_METHOD']} {$wgRequest->getRequestURL()}\n";
|
||||
$debug = "\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
|
||||
|
||||
if ( $wgDebugPrintHttpHeaders ) {
|
||||
$debug .= "HTTP HEADERS:\n";
|
||||
|
|
|
|||
|
|
@ -563,6 +563,15 @@ class WebRequest {
|
|||
return $_GET;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTTP method used for this request.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public function getMethod() {
|
||||
return isset( $_SERVER['REQUEST_METHOD'] ) ? $_SERVER['REQUEST_METHOD'] : 'GET';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the present request was reached by a POST operation,
|
||||
* false otherwise (GET, HEAD, or command-line).
|
||||
|
|
@ -573,7 +582,7 @@ class WebRequest {
|
|||
* @return Boolean
|
||||
*/
|
||||
public function wasPosted() {
|
||||
return isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] == 'POST';
|
||||
return $this->getMethod() == 'POST';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1277,6 +1286,10 @@ class FauxRequest extends WebRequest {
|
|||
}
|
||||
}
|
||||
|
||||
public function getMethod() {
|
||||
return $this->wasPosted ? 'POST' : 'GET';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -352,7 +352,7 @@ class MWDebug {
|
|||
'debugLog' => self::$debug,
|
||||
'queries' => self::$query,
|
||||
'request' => array(
|
||||
'method' => $_SERVER['REQUEST_METHOD'],
|
||||
'method' => $request->getMethod(),
|
||||
'url' => $request->getRequestURL(),
|
||||
'headers' => $request->getAllHeaders(),
|
||||
'params' => $request->getValues(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue