r53034 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53033‎ | r53034 | r53035 >
Date:04:19, 10 July 2009
Author:simetrical
Status:ok
Tags:
Comment:
Experimentally enable HTML 5 doctype

Per wikitech-l discussion. This also removes a <meta> tag that was
completely pointless, but theoretically required by XHTML 1, yet causes
the HTML 5 validator to complain.

Together with a few other recent commits, this should cause at least
Special:BlankPage to validate as HTML 5. Real pages may still have some
invalid markup that should be fixed -- in a large majority of cases,
markup that was poor practice in XHTML as well. (The Wikimedia
copyright icon needs to have border="0" removed for everything to
validate 100% on Wikipedia.)

By Brion's request, this is still behind a config option, and can be
disabled with $wgHtml5 = false;. I expect we'll be able to remove that
option in the near future, once everyone is satisfied that changing two
lines of HTML output that all browsers have demonstrably ignored since
the Paleolithic won't cause all Wikipedia users' computers to undergo a
spontaneous uncontrolled fission reaction or something.
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/OutputPage.php
@@ -1547,7 +1547,7 @@
15481548 public function headElement( Skin $sk ) {
15491549 global $wgDocType, $wgDTD, $wgContLanguageCode, $wgOutputEncoding, $wgMimeType;
15501550 global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces;
1551 - global $wgContLang, $wgUseTrackbacks, $wgStyleVersion;
 1551+ global $wgContLang, $wgUseTrackbacks, $wgStyleVersion, $wgHtml5;
15521552
15531553 $this->addMeta( "http:Content-Type", "$wgMimeType; charset={$wgOutputEncoding}" );
15541554 if ( $sk->commonPrintStylesheet() ) {
@@ -1561,7 +1561,11 @@
15621562 $ret .= "<?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?" . ">\n";
15631563 }
15641564
1565 - $ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\" \"$wgDTD\">\n";
 1565+ if ( $wgHtml5 ) {
 1566+ $ret .= '<!doctype html>';
 1567+ } else {
 1568+ $ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\" \"$wgDTD\">\n";
 1569+ }
15661570
15671571 if ( '' == $this->getHTMLTitle() ) {
15681572 $this->setHTMLTitle( wfMsg( 'pagetitle', $this->getPageTitle() ));
@@ -1592,7 +1596,7 @@
15931597 }
15941598
15951599 protected function addDefaultMeta() {
1596 - global $wgVersion;
 1600+ global $wgVersion, $wgHtml5;
15971601
15981602 static $called = false;
15991603 if ( $called ) {
@@ -1601,7 +1605,9 @@
16021606 }
16031607 $called = true;
16041608
1605 - $this->addMeta( 'http:Content-Style-Type', 'text/css' ); //bug 15835
 1609+ if ( !$wgHtml5 ) {
 1610+ $this->addMeta( 'http:Content-Style-Type', 'text/css' ); //bug 15835
 1611+ }
16061612 $this->addMeta( 'generator', "MediaWiki $wgVersion" );
16071613
16081614 $p = "{$this->mIndexPolicy},{$this->mFollowPolicy}";
Index: trunk/phase3/includes/DefaultSettings.php
@@ -875,6 +875,14 @@
876876 $wgXhtmlDefaultNamespace = 'http://www.w3.org/1999/xhtml';
877877
878878 /**
 879+ * Temporary setting to disable HTML 5 for the unlikely event that it causes
 880+ * everything to blow up. If all goes well, should be removed (and forced
 881+ * true) well before it ever makes it into a release. If set to false, go back
 882+ * to serving an XHTML 1.0 Transitional doctype (per $wgDocType et al. above).
 883+ */
 884+$wgHtml5 = true;
 885+
 886+/**
879887 * Permit other namespaces in addition to the w3.org default.
880888 * Use the prefix for the key and the namespace for the value. For
881889 * example:

Follow-up revisions

RevisionCommit summaryAuthorDate
r53035RELEASE-NOTES for r53034simetrical04:24, 10 July 2009
r53136Fix for r53034: left off \n on doctype...simetrical16:58, 12 July 2009
r53137Turn off $wgHtml5 by default...simetrical17:55, 12 July 2009

Status & tagging log