Drop support for old skins that don't use head element
authorDaniel Friesen <daniel@nadir-seen-fire.com>
Sun, 12 May 2013 08:35:42 +0000 (01:35 -0700)
committerBartosz Dziewoński <matma.rex@gmail.com>
Sat, 31 May 2014 13:30:19 +0000 (15:30 +0200)
These skins have been obsolete since 1.16 and aren't supported well at this point.
This deprecates those skins and begins deprecation of the creation of <head> contents
with only chunks of OutputPage stuff. The entire head should be created by OutputPage.

This also deprecates some old methods responsible for returning raw chunks of html for the head:
* getScript
* getHeadItems

Output of HeadItems is also tweaked. Previously there was no newline added
after each item, now there is. Most of the callers of addHeadItem don't use
their own newline and as a result end up on one line.

Change-Id: I13e25cc8d8fc3aa682f23b019a2fda0e809a5f64

RELEASE-NOTES-1.24
includes/OutputPage.php
includes/SkinTemplate.php
skins/MonoBook.php
skins/Vector.php

index b3b34f2..3683fcc 100644 (file)
@@ -118,6 +118,10 @@ changes to languages because of Bugzilla reports.
   core to their own respective repositories. See also
   https://www.mediawiki.org/wiki/Skin:Modern and
   https://www.mediawiki.org/wiki/Skin:CologneBlue.
+* BREAKING CHANGE: Skins built for MediaWiki 1.15 and earlier that do not use
+  the "headelement" template key are no longer supported. Setting
+  $useHeadElement = false; is no longer supported and will not cause old keys
+  like "headlinks", "skinnameclass", etc. to be defined.
 
 ==== Renamed classes ====
 * CLDRPluralRuleConverter_Expression to CLDRPluralRuleConverterExpression
index 0f3612a..6075d8d 100644 (file)
@@ -473,8 +473,10 @@ class OutputPage extends ContextSource {
         * Get all registered JS and CSS tags for the header.
         *
         * @return string
+        * @deprecated since 1.24 Use OutputPage::headElement to build the full header.
         */
        function getScript() {
+               wfDeprecated( __METHOD__, '1.24' );
                return $this->mScripts . $this->getHeadItems();
        }
 
@@ -630,8 +632,11 @@ class OutputPage extends ContextSource {
         * Get all header items in a string
         *
         * @return string
+        * @deprecated since 1.24 Use OutputPage::headElement or
+        *   if absolutely necessary use OutputPage::getHeadItemsArray
         */
        function getHeadItems() {
+               wfDeprecated( __METHOD__, '1.24' );
                $s = '';
                foreach ( $this->mHeadItems as $item ) {
                        $s .= $item;
@@ -2585,15 +2590,18 @@ $templates
 
                $ret .= Html::element( 'title', null, $this->getHTMLTitle() ) . "\n";
 
-               $ret .= (
-                       $this->getHeadLinks() .
-                       "\n" .
-                       $this->buildCssLinks() .
-                       // No newline after buildCssLinks since makeResourceLoaderLink did that already
-                       $this->getHeadScripts() .
-                       "\n" .
-                       $this->getHeadItems()
-               );
+               foreach ( $this->getHeadLinksArray() as $item ) {
+                       $ret .= $item . "\n";
+               }
+
+               // No newline after buildCssLinks since makeResourceLoaderLink did that already
+               $ret .= $this->buildCssLinks();
+
+               $ret .= $this->getHeadScripts() . "\n";
+
+               foreach ( $this->mHeadItems as $item ) {
+                       $ret .= $item . "\n";
+               }
 
                $closeHead = Html::closeElement( 'head' );
                if ( $closeHead ) {
@@ -3434,8 +3442,11 @@ $templates
 
        /**
         * @return string HTML tag links to be put in the header.
+        * @deprecated since 1.24 Use OutputPage::headElement or if you have to,
+        *   OutputPage::getHeadLinksArray directly.
         */
        public function getHeadLinks() {
+               wfDeprecated( __METHOD__, '1.24' );
                return implode( "\n", $this->getHeadLinksArray() );
        }
 
index 08816ad..86bd979 100644 (file)
@@ -86,12 +86,6 @@ class SkinTemplate extends Skin {
         */
        public $template = 'QuickTemplate';
 
-       /**
-        * @var bool Whether this skin use OutputPage::headElement() to generate
-        *   the "<head>" tag.
-        */
-       public $useHeadElement = false;
-
        /**
         * Add specific styles for this skin
         *
@@ -290,26 +284,6 @@ class SkinTemplate extends Skin {
                $out = $this->getOutput();
                $tpl = $this->setupTemplateForOutput();
 
-               wfProfileIn( __METHOD__ . '-stuff-head' );
-               if ( !$this->useHeadElement ) {
-                       $tpl->set( 'pagecss', false );
-                       $tpl->set( 'usercss', false );
-
-                       $tpl->set( 'userjs', false );
-                       $tpl->set( 'userjsprev', false );
-
-                       $tpl->set( 'jsvarurl', false );
-
-                       $tpl->set( 'xhtmldefaultnamespace', 'http://www.w3.org/1999/xhtml' );
-                       $tpl->set( 'xhtmlnamespaces', $wgXhtmlNamespaces );
-                       $tpl->set( 'html5version', $wgHtml5Version );
-                       $tpl->set( 'headlinks', $out->getHeadLinks() );
-                       $tpl->set( 'csslinks', $out->buildCssLinks() );
-                       $tpl->set( 'pageclass', $this->getPageClasses( $title ) );
-                       $tpl->set( 'skinnameclass', ( 'skin-' . Sanitizer::escapeClass( $this->getSkinName() ) ) );
-               }
-               wfProfileOut( __METHOD__ . '-stuff-head' );
-
                wfProfileIn( __METHOD__ . '-stuff2' );
                $tpl->set( 'title', $out->getPageTitle() );
                $tpl->set( 'pagetitle', $out->getHTMLTitle() );
@@ -540,11 +514,7 @@ class SkinTemplate extends Skin {
                $tpl->set( 'nav_urls', $this->buildNavUrls() );
 
                // Set the head scripts near the end, in case the above actions resulted in added scripts
-               if ( $this->useHeadElement ) {
-                       $tpl->set( 'headelement', $out->headElement( $this ) );
-               } else {
-                       $tpl->set( 'headscripts', $out->getHeadScripts() . $out->getHeadItems() );
-               }
+               $tpl->set( 'headelement', $out->headElement( $this ) );
 
                $tpl->set( 'debug', '' );
                $tpl->set( 'debughtml', $this->generateDebugHTML() );
index 72056b9..7385d0e 100644 (file)
@@ -39,7 +39,6 @@ class SkinMonoBook extends SkinTemplate {
        public $skinname = 'monobook';
        public $stylename = 'monobook';
        public $template = 'MonoBookTemplate';
-       public $useHeadElement = true;
 
        /**
         * @param OutputPage $out
index 35861c2..db731af 100644 (file)
@@ -32,7 +32,6 @@ if ( !defined( 'MEDIAWIKI' ) ) {
  * @ingroup Skins
  */
 class SkinVector extends SkinTemplate {
-       public $useHeadElement = true;
        public $skinname = 'vector';
        public $stylename = 'vector';
        public $template = 'VectorTemplate';