This is to replace the usage of $_SERVER['REQUEST_METHOD'].
Change-Id: I45084254c5452b00b0665df78628cfd214e39cab
# 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";
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).
* @return Boolean
*/
public function wasPosted() {
- return isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] == 'POST';
+ return $this->getMethod() == 'POST';
}
/**
}
}
+ public function getMethod() {
+ return $this->wasPosted ? 'POST' : 'GET';
+ }
+
/**
* @return bool
*/
'debugLog' => self::$debug,
'queries' => self::$query,
'request' => array(
- 'method' => $_SERVER['REQUEST_METHOD'],
+ 'method' => $request->getMethod(),
'url' => $request->getRequestURL(),
'headers' => $request->getAllHeaders(),
'params' => $request->getValues(),