From 0f6609447e8cbd1d371e40b3fdd919bf71c3f5df Mon Sep 17 00:00:00 2001 From: Daniel Friesen Date: Sun, 12 May 2013 01:35:42 -0700 Subject: [PATCH] Drop support for old skins that don't use head element 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 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 | 4 ++++ includes/OutputPage.php | 29 ++++++++++++++++++++--------- includes/SkinTemplate.php | 32 +------------------------------- skins/MonoBook.php | 1 - skins/Vector.php | 1 - 5 files changed, 25 insertions(+), 42 deletions(-) diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24 index b3b34f2985..3683fccc30 100644 --- a/RELEASE-NOTES-1.24 +++ b/RELEASE-NOTES-1.24 @@ -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 diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 0f3612a89f..6075d8dbc5 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -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() ); } diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 08816add7f..86bd9797a9 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -86,12 +86,6 @@ class SkinTemplate extends Skin { */ public $template = 'QuickTemplate'; - /** - * @var bool Whether this skin use OutputPage::headElement() to generate - * the "" 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() ); diff --git a/skins/MonoBook.php b/skins/MonoBook.php index 72056b953c..7385d0ea8f 100644 --- a/skins/MonoBook.php +++ b/skins/MonoBook.php @@ -39,7 +39,6 @@ class SkinMonoBook extends SkinTemplate { public $skinname = 'monobook'; public $stylename = 'monobook'; public $template = 'MonoBookTemplate'; - public $useHeadElement = true; /** * @param OutputPage $out diff --git a/skins/Vector.php b/skins/Vector.php index 35861c2286..db731af16c 100644 --- a/skins/Vector.php +++ b/skins/Vector.php @@ -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'; -- 2.20.1