jenkins-bot has submitted this change and it was merged.

Change subject: OutputPage: Move our <meta charset="...> so it's placed above 
the title
......................................................................


OutputPage: Move our <meta charset="...> so it's placed above the title

It's recommended for the meta charset to be placed before the <title> since
<title> contains text which is inside the character set defined by the meta 
charset.

Use of meta charset inside XHTML also seems to be redundant, not recommended,
and is very likely completely ignored.

Change-Id: I335b0598a9615540dc5e917682508b4a8d32d96e
---
M includes/OutputPage.php
1 file changed, 17 insertions(+), 16 deletions(-)

Approvals:
  Parent5446: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/OutputPage.php b/includes/OutputPage.php
index d379e46..43f27bd 100644
--- a/includes/OutputPage.php
+++ b/includes/OutputPage.php
@@ -2474,7 +2474,7 @@
         * @return String: The doctype, opening "<html>", and head element.
         */
        public function headElement( Skin $sk, $includeStyle = true ) {
-               global $wgContLang;
+               global $wgContLang, $wgMimeType;
 
                $userdir = $this->getLanguage()->getDir();
                $sitedir = $wgContLang->getDir();
@@ -2495,10 +2495,22 @@
                        $ret .= "$openHead\n";
                }
 
+               if ( !Html::isXmlMimeType( $wgMimeType ) ) {
+                       // Add <meta charset="UTF-8">
+                       // This should be before <title> since it defines the 
charset used by
+                       // text including the text inside <title>.
+                       // The spec recommends defining XHTML5's charset using 
the XML declaration
+                       // instead of meta.
+                       // Our XML declaration is output by Html::htmlHeader.
+                       // 
http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#attr-meta-http-equiv-content-type
+                       // 
http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#charset
+                       $ret .= Html::element( 'meta', array( 'charset' => 
'UTF-8' ) );
+               }
+
                $ret .= Html::element( 'title', null, $this->getHTMLTitle() ) . 
"\n";
 
                $ret .= implode( "\n", array(
-                       $this->getHeadLinks( null, true ),
+                       $this->getHeadLinks(),
                        $this->buildCssLinks(),
                        $this->getHeadScripts(),
                        $this->getHeadItems()
@@ -3127,11 +3139,9 @@
        }
 
        /**
-        * @param bool $addContentType Whether "<meta>" specifying content type 
should be returned
-        *
         * @return array in format "link name or number => 'link html'".
         */
-       public function getHeadLinksArray( $addContentType = false ) {
+       public function getHeadLinksArray() {
                global $wgUniversalEditButton, $wgFavicon, $wgAppleTouchIcon, 
$wgEnableAPI,
                        $wgSitename, $wgVersion,
                        $wgFeed, $wgOverrideSiteFeed, $wgAdvertisedFeedTypes,
@@ -3141,12 +3151,6 @@
                $tags = array();
 
                $canonicalUrl = $this->mCanonicalUrl;
-
-               if ( $addContentType ) {
-                       # More succinct than <meta http-equiv=Content-Type>, 
has the
-                       # same effect
-                       $tags['meta-charset'] = Html::element( 'meta', array( 
'charset' => 'UTF-8' ) );
-               }
 
                $tags['meta-generator'] = Html::element( 'meta', array(
                        'name' => 'generator',
@@ -3365,13 +3369,10 @@
        }
 
        /**
-        * @param $unused
-        * @param bool $addContentType Whether "<meta>" specifying content type 
should be returned
-        *
         * @return string HTML tag links to be put in the header.
         */
-       public function getHeadLinks( $unused = null, $addContentType = false ) 
{
-               return implode( "\n", $this->getHeadLinksArray( $addContentType 
) );
+       public function getHeadLinks() {
+               return implode( "\n", $this->getHeadLinksArray() );
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/63267
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I335b0598a9615540dc5e917682508b4a8d32d96e
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Daniel Friesen <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Daniel Friesen <[email protected]>
Gerrit-Reviewer: Demon <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: MZMcBride <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: Peachey88 <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: Waldir <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to