X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FWebRequest.php;h=9d0e579a8b050e40f1ace8d080b7513c4c520714;hb=557a05f3843c486e79e01da32c1baa397a352c9a;hp=cd0fd20ca7d7cccd3d3678b11454d0a2707abe37;hpb=85bbb0b080cc721093088f15913aada1043db04c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/WebRequest.php b/includes/WebRequest.php index cd0fd20ca7..9d0e579a8b 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -77,6 +77,7 @@ class WebRequest { * @return Array: Any query arguments found in path matches. */ static public function getPathInfo( $want = 'all' ) { + global $wgUsePathInfo; // PATH_INFO is mangled due to http://bugs.php.net/bug.php?id=31892 // And also by Apache 2.x, double slashes are converted to single slashes. // So we will use REQUEST_URI if possible. @@ -134,15 +135,17 @@ class WebRequest { $matches = $router->parse( $path ); } - } elseif ( isset( $_SERVER['ORIG_PATH_INFO'] ) && $_SERVER['ORIG_PATH_INFO'] != '' ) { - // Mangled PATH_INFO - // http://bugs.php.net/bug.php?id=31892 - // Also reported when ini_get('cgi.fix_pathinfo')==false - $matches['title'] = substr( $_SERVER['ORIG_PATH_INFO'], 1 ); - - } elseif ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER['PATH_INFO'] != '') ) { - // Regular old PATH_INFO yay - $matches['title'] = substr( $_SERVER['PATH_INFO'], 1 ); + } elseif ( $wgUsePathInfo ) { + if ( isset( $_SERVER['ORIG_PATH_INFO'] ) && $_SERVER['ORIG_PATH_INFO'] != '' ) { + // Mangled PATH_INFO + // http://bugs.php.net/bug.php?id=31892 + // Also reported when ini_get('cgi.fix_pathinfo')==false + $matches['title'] = substr( $_SERVER['ORIG_PATH_INFO'], 1 ); + + } elseif ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER['PATH_INFO'] != '') ) { + // Regular old PATH_INFO yay + $matches['title'] = substr( $_SERVER['PATH_INFO'], 1 ); + } } return $matches; @@ -206,18 +209,14 @@ class WebRequest { * available variant URLs. */ public function interpolateTitle() { - global $wgUsePathInfo; - // bug 16019: title interpolation on API queries is useless and sometimes harmful if ( defined( 'MW_API' ) ) { return; } - if ( $wgUsePathInfo ) { - $matches = self::getPathInfo( 'title' ); - foreach( $matches as $key => $val) { - $this->data[$key] = $_GET[$key] = $_REQUEST[$key] = $val; - } + $matches = self::getPathInfo( 'title' ); + foreach( $matches as $key => $val) { + $this->data[$key] = $_GET[$key] = $_REQUEST[$key] = $val; } } @@ -298,8 +297,8 @@ class WebRequest { /** * Recursively normalizes UTF-8 strings in the given array. * - * @param $data string or array - * @return cleaned-up version of the given + * @param $data string|array + * @return array|string cleaned-up version of the given * @private */ function normalizeUnicode( $data ) { @@ -379,6 +378,23 @@ class WebRequest { return $ret; } + + /** + * Unset an arbitrary value from our get/post data. + * + * @param $key String: key name to use + * @return Mixed: old value if one was present, null otherwise + */ + public function unsetVal( $key ) { + if ( !isset( $this->data[$key] ) ) { + $ret = null; + } else { + $ret = $this->data[$key]; + unset( $this->data[$key] ); + } + return $ret; + } + /** * 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. @@ -518,7 +534,7 @@ class WebRequest { $retVal = array(); foreach ( $names as $name ) { - $value = $this->getVal( $name ); + $value = $this->getGPCVal( $this->data, $name, null ); if ( !is_null( $value ) ) { $retVal[$name] = $value; } @@ -838,7 +854,7 @@ class WebRequest { * Get a request header, or false if it isn't set * @param $name String: case-insensitive header name * - * @return string|bool + * @return string|bool False on failure */ public function getHeader( $name ) { $this->initHeaders(); @@ -1336,6 +1352,7 @@ class FauxRequest extends WebRequest { * (cookies, session and headers). * * @ingroup HTTP + * @since 1.19 */ class DerivativeRequest extends FauxRequest { private $base; @@ -1366,7 +1383,7 @@ class DerivativeRequest extends FauxRequest { } public function setSessionData( $key, $data ) { - return $this->base->setSessionData( $key, $data ); + $this->base->setSessionData( $key, $data ); } public function getAcceptLang() {