X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FWebRequest.php;h=c94e8d4e23113113fa94af4441d41bd4ca159bc4;hp=9b8f5a69f5d46c0f2ce234fa88ff9015b3ebcf67;hb=25242105e8fd03c9900250bdf9ea91be9a286625;hpb=25be8cc5859e2f9f6560d6d1d52a47888023fbd6 diff --git a/includes/WebRequest.php b/includes/WebRequest.php index 9b8f5a69f5..c94e8d4e23 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -40,9 +40,28 @@ use Wikimedia\AtEase\AtEase; * @ingroup HTTP */ class WebRequest { - /** @var array */ + /** + * The parameters from $_GET, $_POST and the path router + * @var array + */ protected $data; - /** @var array */ + + /** + * The parameters from $_GET. The parameters from the path router are + * added by interpolateTitle() during Setup.php. + * @var array + */ + protected $queryAndPathParams; + + /** + * The parameters from $_GET only. + */ + protected $queryParams; + + /** + * Lazy-initialized request headers indexed by upper-case header name + * @var array + */ protected $headers = []; /** @@ -100,6 +119,8 @@ class WebRequest { // POST overrides GET data // We don't use $_REQUEST here to avoid interference from cookies... $this->data = $_POST + $_GET; + + $this->queryAndPathParams = $this->queryParams = $_GET; } /** @@ -162,8 +183,9 @@ class WebRequest { } global $wgActionPaths; - if ( $wgActionPaths ) { - $router->add( $wgActionPaths, [ 'action' => '$key' ] ); + $articlePaths = PathRouter::getActionPaths( $wgActionPaths, $wgArticlePath ); + if ( $articlePaths ) { + $router->add( $articlePaths, [ 'action' => '$key' ] ); } global $wgVariantArticlePath; @@ -335,7 +357,7 @@ class WebRequest { $matches = self::getPathInfo( 'title' ); foreach ( $matches as $key => $val ) { - $this->data[$key] = $_GET[$key] = $_REQUEST[$key] = $val; + $this->data[$key] = $this->queryAndPathParams[$key] = $val; } } @@ -525,7 +547,7 @@ class WebRequest { * * @param string $name * @param array|null $default Option default (or null) - * @return array Array of ints + * @return int[]|null */ public function getIntArray( $name, $default = null ) { $val = $this->getArray( $name, $default ); @@ -667,14 +689,27 @@ class WebRequest { } /** - * Get the values passed in the query string. + * Get the values passed in the query string and the path router parameters. * No transformation is performed on the values. * * @codeCoverageIgnore * @return array */ public function getQueryValues() { - return $_GET; + return $this->queryAndPathParams; + } + + /** + * 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. + * + * @since 1.34 + * @return array + */ + public function getQueryValuesOnly() { + return $this->queryParams; } /**