Merge "(bug 37755) Set robot meta tags for 'view source' pages"
[lhc/web/wiklou.git] / includes / OutputPage.php
index 3578568..7649b23 100644 (file)
@@ -611,7 +611,7 @@ class OutputPage extends ContextSource {
 
        /**
         * checkLastModified tells the client to use the client-cached page if
-        * possible. If sucessful, the OutputPage is disabled so that
+        * possible. If successful, the OutputPage is disabled so that
         * any future call to OutputPage->output() have no effect.
         *
         * Side effect: sets mLastModified for Last-Modified header
@@ -1469,7 +1469,7 @@ class OutputPage extends ContextSource {
         * @param $interface Boolean: whether it is an interface message
         *                                                              (for example disables conversion)
         */
-       public function addWikiTextTitle( $text, &$title, $linestart, $tidy = false, $interface = false ) {
+       public function addWikiTextTitle( $text, Title $title, $linestart, $tidy = false, $interface = false ) {
                global $wgParser;
 
                wfProfileIn( __METHOD__ );
@@ -1769,14 +1769,12 @@ class OutputPage extends ContextSource {
                                } else {
                                        $aloption[] = 'string-contains=' . $variant;
 
-                                       // IE and some other browsers use another form of language code
-                                       // in their Accept-Language header, like "zh-CN" or "zh-TW".
+                                       // IE and some other browsers use BCP 47 standards in
+                                       // their Accept-Language header, like "zh-CN" or "zh-Hant".
                                        // We should handle these too.
-                                       $ievariant = explode( '-', $variant );
-                                       if ( count( $ievariant ) == 2 ) {
-                                               $ievariant[1] = strtoupper( $ievariant[1] );
-                                               $ievariant = implode( '-', $ievariant );
-                                               $aloption[] = 'string-contains=' . $ievariant;
+                                       $variantBCP47 = wfBCP47( $variant );
+                                       if ( $variantBCP47 !== $variant ) {
+                                               $aloption[] = 'string-contains=' . $variantBCP47;
                                        }
                                }
                        }
@@ -2982,7 +2980,7 @@ $templates
                );
                if ( $wgContLang->hasVariants() ) {
                        $vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
-               }
+               }
                foreach ( $title->getRestrictionTypes() as $type ) {
                        $vars['wgRestriction' . ucfirst( $type )] = $title->getRestrictions( $type );
                }