r60870 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60869‎ | r60870 | r60871 >
Date:19:04, 9 January 2010
Author:siebrand
Status:deferred
Tags:
Comment:
(bug 21173) Provide rel="canonical" for funky URL parameters and other things beyond redirects. Patch contributed by Jools Wills.

Comment in report: CanonicalHref does not work with the 1.16alpha skins. This patch makes it work. Changed the hook and used wgOut->addLink instead of $template->set('headlinks', $template->data['headlinks'] ... );
Modified paths:
  • /trunk/extensions/CanonicalHref/CanonicalHref.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CanonicalHref/CanonicalHref.php
@@ -11,7 +11,7 @@
1212 * https://wikia-code.com/wikia/trunk/extensions/wikia/HardRedirectsWithJSText/
1313 */
1414
15 -$wgHooks['SkinTemplateOutputPageBeforeExec'][] = "canonicalHref";
 15+$wgHooks['BeforePageDisplay'][] = "canonicalHref";
1616
1717 $wgExtensionCredits['specialpage'][] = array(
1818 'path' => __FILE__,
@@ -21,13 +21,13 @@
2222 );
2323
2424
25 -function canonicalHref(&$skin, &$template){
26 - $link = Xml::element("link", array(
27 - 'rel' => 'canonical',
28 - 'href' => $skin->mTitle->getFullURL()
 25+function canonicalHref(&$out, &$skin){
 26+ $out->addLink(
 27+ array(
 28+ 'rel' => 'canonical',
 29+ 'href' => $skin->mTitle->getFullURL()
2930 )
3031 );
31 - $template->set('headlinks', $template->data['headlinks'] . "\n" . $link . "\n");
3232 return true;
3333 }
3434

Status & tagging log