Merge "Give search results a consistent css class to select"
[lhc/web/wiklou.git] / includes / WebRequest.php
index b499d86..327dd54 100644 (file)
@@ -162,11 +162,12 @@ class WebRequest {
                                        $router->add( $wgActionPaths, [ 'action' => '$key' ] );
                                }
 
-                               global $wgVariantArticlePath, $wgContLang;
+                               global $wgVariantArticlePath;
                                if ( $wgVariantArticlePath ) {
                                        $router->add( $wgVariantArticlePath,
                                                [ 'variant' => '$2' ],
-                                               [ '$2' => $wgContLang->getVariants() ]
+                                               [ '$2' => MediaWikiServices::getInstance()->getContentLanguage()->
+                                               getVariants() ]
                                        );
                                }
 
@@ -306,7 +307,7 @@ class WebRequest {
        /**
         * Check for title, action, and/or variant data in the URL
         * and interpolate it into the GET variables.
-        * This should only be run after $wgContLang is available,
+        * This should only be run after the content language is available,
         * as we may need the list of language variants to determine
         * available variant URLs.
         */
@@ -364,9 +365,8 @@ class WebRequest {
                                $data[$key] = $this->normalizeUnicode( $val );
                        }
                } else {
-                       global $wgContLang;
-                       $data = isset( $wgContLang ) ?
-                               $wgContLang->normalize( $data ) :
+                       $contLang = MediaWikiServices::getInstance()->getContentLanguage();
+                       $data = $contLang ? $contLang->normalize( $data ) :
                                UtfNormal\Validator::cleanUp( $data );
                }
                return $data;
@@ -386,12 +386,12 @@ class WebRequest {
                # Work around PHP *feature* to avoid *bugs* elsewhere.
                $name = strtr( $name, '.', '_' );
                if ( isset( $arr[$name] ) ) {
-                       global $wgContLang;
                        $data = $arr[$name];
                        if ( isset( $_GET[$name] ) && !is_array( $data ) ) {
                                # Check for alternate/legacy character encoding.
-                               if ( isset( $wgContLang ) ) {
-                                       $data = $wgContLang->checkTitleEncoding( $data );
+                               $contLang = MediaWikiServices::getInstance()->getContentLanguage();
+                               if ( $contLang ) {
+                                       $data = $contLang->checkTitleEncoding( $data );
                                }
                        }
                        $data = $this->normalizeUnicode( $data );
@@ -484,7 +484,7 @@ class WebRequest {
         * 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 ) {
@@ -503,7 +503,7 @@ class WebRequest {
         * 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 ) {
@@ -776,8 +776,8 @@ class WebRequest {
         * 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 ) {
@@ -856,7 +856,7 @@ class WebRequest {
         * @return string
         */
        public function getFullRequestURL() {
-               return wfExpandUrl( $this->getRequestURL(), PROTO_CURRENT );
+               return wfGetServerUrl( PROTO_CURRENT ) .  $this->getRequestURL();
        }
 
        /**