use MediaWiki\Session\SessionId;
use MediaWiki\Session\SessionManager;
+// The point of this class is to be a wrapper around super globals
+// phpcs:disable MediaWiki.Usage.SuperGlobalsUsage.SuperGlobals
+
/**
* The WebRequest class encapsulates getting at data passed in the
* URL or via a POSTed form stripping illegal input characters and
$a = parse_url( $url );
Wikimedia\restoreWarnings();
if ( $a ) {
- $path = isset( $a['path'] ) ? $a['path'] : '';
+ $path = $a['path'] ?? '';
global $wgScript;
if ( $path == $wgScript && $want !== 'all' ) {
// This method is called from various error handlers and should be kept simple.
if ( !self::$reqId ) {
- self::$reqId = isset( $_SERVER['UNIQUE_ID'] )
- ? $_SERVER['UNIQUE_ID'] : wfRandomString( 24 );
+ self::$reqId = $_SERVER['UNIQUE_ID'] ?? wfRandomString( 24 );
}
return self::$reqId;
* @return mixed Old value if one was present, null otherwise
*/
public function setVal( $key, $value ) {
- $ret = isset( $this->data[$key] ) ? $this->data[$key] : null;
+ $ret = $this->data[$key] ?? null;
$this->data[$key] = $value;
return $ret;
}
* If no source and no default, returns null.
*
* @param string $name
- * @param array $default Optional default (or null)
+ * @param array|null $default Optional default (or null)
* @return array|null
*/
public function getArray( $name, $default = null ) {
* If an array is returned, contents are guaranteed to be integers.
*
* @param string $name
- * @param array $default Option default (or null)
+ * @param array|null $default Option default (or null)
* @return array Array of ints
*/
public function getIntArray( $name, $default = null ) {
return $_GET;
}
+ /**
+ * Get the values passed via POST.
+ * No transformation is performed on the values.
+ *
+ * @since 1.32
+ * @codeCoverageIgnore
+ * @return array
+ */
+ public function getPostValues() {
+ return $_POST;
+ }
+
/**
* 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.
* @return string
*/
public function getMethod() {
- return isset( $_SERVER['REQUEST_METHOD'] ) ? $_SERVER['REQUEST_METHOD'] : 'GET';
+ return $_SERVER['REQUEST_METHOD'] ?? 'GET';
}
/**
* Get a cookie from the $_COOKIE jar
*
* @param string $key The name of the cookie
- * @param string $prefix A prefix to use for the cookie name, if not $wgCookiePrefix
- * @param mixed $default What to return if the value isn't found
+ * @param string|null $prefix A prefix to use for the cookie name, if not $wgCookiePrefix
+ * @param mixed|null $default What to return if the value isn't found
* @return mixed Cookie value or $default if the cookie not set
*/
public function getCookie( $key, $prefix = null, $default = null ) {
* @return string
*/
public function getFullRequestURL() {
- return wfExpandUrl( $this->getRequestURL(), PROTO_CURRENT );
+ return wfGetServerUrl( PROTO_CURRENT ) . $this->getRequestURL();
}
/**