From e9a9e4999e848dd0bf0e18d305270455f5e8f199 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Sat, 5 Nov 2011 20:25:00 +0000 Subject: [PATCH] * Only call Title::getPageLanguage() when necessary, i.e. after "!$wgDisableLangConversion && $wgCanonicalLanguageLinks" check passed * Removed creation of Special:Recentchanges' Title object and use Title::isSpecial() instead --- includes/OutputPage.php | 44 ++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index bad955c3b1..0a81ecd9c5 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2895,28 +2895,29 @@ $templates ) ); } - $lang = $this->getTitle()->getPageLanguage(); # Language variants - if ( !$wgDisableLangConversion && $wgCanonicalLanguageLinks - && $lang->hasVariants() ) { - - $urlvar = $lang->getURLVariant(); - - if ( !$urlvar ) { - $variants = $lang->getVariants(); - foreach ( $variants as $_v ) { + if ( !$wgDisableLangConversion && $wgCanonicalLanguageLinks ) { + $lang = $this->getTitle()->getPageLanguage(); + if ( $lang->hasVariants() ) { + + $urlvar = $lang->getURLVariant(); + + if ( !$urlvar ) { + $variants = $lang->getVariants(); + foreach ( $variants as $_v ) { + $tags[] = Html::element( 'link', array( + 'rel' => 'alternate', + 'hreflang' => $_v, + 'href' => $this->getTitle()->getLocalURL( '', $_v ) ) + ); + } + } else { $tags[] = Html::element( 'link', array( - 'rel' => 'alternate', - 'hreflang' => $_v, - 'href' => $this->getTitle()->getLocalURL( '', $_v ) ) - ); + 'rel' => 'canonical', + 'href' => $this->getTitle()->getCanonicalUrl() + ) ); } - } else { - $tags[] = Html::element( 'link', array( - 'rel' => 'canonical', - 'href' => $this->getTitle()->getCanonicalUrl() - ) ); } } @@ -2964,9 +2965,6 @@ $templates # like to promote instead of the RC feed (maybe like a "Recent New Articles" # or "Breaking news" one). For this, we see if $wgOverrideSiteFeed is defined. # If so, use it instead. - - $rctitle = SpecialPage::getTitleFor( 'Recentchanges' ); - if ( $wgOverrideSiteFeed ) { foreach ( $wgOverrideSiteFeed as $type => $feedUrl ) { // Note, this->feedLink escapes the url. @@ -2976,11 +2974,11 @@ $templates $this->msg( "site-{$type}-feed", $wgSitename )->text() ); } - } elseif ( $this->getTitle()->getPrefixedText() != $rctitle->getPrefixedText() ) { + } elseif ( !$this->getTitle()->isSpecial( 'Recentchanges' ) ) { foreach ( $wgAdvertisedFeedTypes as $format ) { $tags[] = $this->feedLink( $format, - $rctitle->getLocalURL( "feed={$format}" ), + $this->getTitle()->getLocalURL( "feed={$format}" ), $this->msg( "site-{$format}-feed", $wgSitename )->text() # For grep: 'site-rss-feed', 'site-atom-feed'. ); } -- 2.20.1