* Use only default options when generating RSS and Atom syndication links.
authorBrion Vibber <brion@users.mediawiki.org>
Sat, 12 Jan 2008 00:13:53 +0000 (00:13 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sat, 12 Jan 2008 00:13:53 +0000 (00:13 +0000)
  This should help prevent infinite link loops that some software may follow,
  and will generally keep feed behavior cleaner.

Combined duplicate link expansion from OutputPage and SkinTemplate into OutputPage::getSyndicationLinks()

RELEASE-NOTES
includes/OutputPage.php
includes/PageHistory.php
includes/SkinTemplate.php

index 4dd9771..1ecb203 100644 (file)
@@ -298,6 +298,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Do not log user rights change that didn't change anything
 * (bug 12584) Don't reset cl_timestamp when auto-updating sort key on move
 * (bug 12588) Fix selection in namespace selector on Special:Newpages
+* Use only default options when generating RSS and Atom syndication links.
+  This should help prevent infinite link loops that some software may follow,
+  and will generally keep feed behavior cleaner.
 
 
 == Parser changes in 1.12 ==
index 6e50960..7c5af28 100644 (file)
@@ -1298,25 +1298,17 @@ class OutputPage {
                        $ret .= " />\n";
                }
                
-               if( $this->isSyndicated() ) {
+               foreach( $this->getSyndicationLinks() as $format => $link ) {
                        # Use the page name for the title (accessed through $wgTitle since
                        # there's no other way).  In principle, this could lead to issues
                        # with having the same name for different feeds corresponding to
                        # the same page, but we can't avoid that at this low a level.
-                       global $wgTitle, $wgFeedClasses;
-                       
-                       if( is_string( $this->getFeedAppendQuery() ) ) {
-                               $appendQuery = "&" . $this->getFeedAppendQuery();
-                       } else {
-                               $appendQuery = "";
-                       }
+                       global $wgTitle;
 
-                       foreach( $wgFeedClasses as $format => $class ) {
-                               $ret .= $this->feedLink(
-                                       $format,
-                                       $wgRequest->appendQuery( "feed=$format{$appendQuery}" ),
-                                       wfMsg( "page-{$format}-feed", $wgTitle->getPrefixedText() ) );
-                       }
+                       $ret .= $this->feedLink(
+                               $format,
+                               $link,
+                               wfMsg( "page-{$format}-feed", $wgTitle->getPrefixedText() ) );
                }
 
                # Recent changes feed should appear on every page
@@ -1336,6 +1328,28 @@ class OutputPage {
                return $ret;
        }
        
+       /**
+        * Return URLs for each supported syndication format for this page.
+        * @return array associating format keys with URLs
+        */
+       public function getSyndicationLinks() {
+               global $wgTitle, $wgFeedClasses;
+               $links = array();
+               
+               if( $this->isSyndicated() ) {
+                       if( is_string( $this->getFeedAppendQuery() ) ) {
+                               $appendQuery = "&" . $this->getFeedAppendQuery();
+                       } else {
+                               $appendQuery = "";
+                       }
+
+                       foreach( $wgFeedClasses as $format => $class ) {
+                               $links[$format] = $wgTitle->getLocalUrl( "feed=$format{$appendQuery}" );
+                       }
+               }
+               return $links;
+       }
+       
        /**
         * Generate a <link rel/> for an RSS feed.
         */
index 9d84665..3c8c8a1 100644 (file)
@@ -67,6 +67,7 @@ class PageHistory {
                $wgOut->setArticleRelated( true );
                $wgOut->setRobotpolicy( 'noindex,nofollow' );
                $wgOut->setSyndicated( true );
+               $wgOut->setFeedAppendQuery( 'action=history' );
 
                $logPage = SpecialPage::getTitleFor( 'Log' );
                $logLink = $this->mSkin->makeKnownLinkObj( $logPage, wfMsgHtml( 'viewpagelogs' ), 'page=' . $this->mTitle->getPrefixedUrl() );
index 9ba8030..d013119 100644 (file)
@@ -219,22 +219,10 @@ class SkinTemplate extends Skin {
                $tpl->set( 'catlinks', $this->getCategories());
                if( $wgOut->isSyndicated() ) {
                        $feeds = array();
-                       foreach( $wgFeedClasses as $format => $class ) {
-                               $linktext = $format;
-                               if ( $format == "atom" ) {
-                                       $linktext = wfMsg( 'feed-atom' );
-                               } else if ( $format == "rss" ) {
-                                       $linktext = wfMsg( 'feed-rss' );
-                               }
-                               if( is_string( $wgOut->getFeedAppendQuery() ) ) {
-                                       $appendQuery = "&" . $wgOut->getFeedAppendQuery();
-                               } else {
-                                       $appendQuery = "";
-                               }
+                       foreach( $wgOut->getSyndicationLinks() as $format => $link ) {
                                $feeds[$format] = array(
-                                       'text' => $linktext,
-                                       'href' => $wgRequest->appendQuery( "feed={$format}{$appendQuery}" )
-                               );
+                                       'text' => wfMsg( "feed-$format" ),
+                                       'href' => $link );
                        }
                        $tpl->setRef( 'feeds', $feeds );
                } else {