(bug 28401) Make RC en RCL honour options for rss/atom
authormrbluesky <mrbluesky@wikipedia.be>
Thu, 13 Dec 2012 21:59:02 +0000 (22:59 +0100)
committerGerrit Code Review <gerrit@wikimedia.org>
Sun, 16 Dec 2012 10:34:23 +0000 (10:34 +0000)
RecentChanges and RecentChangesLinked should link to atom/rss feeds using the same options as specified for the pages themselves. E.g. if somebody is looking at Special:RecentChanges&hideliu=1&namespace=1 the feed(s) should link to Special:RecentChanges&feed=atom&hideliu=1&namespace=1. All options available on RC and RCL are already supported by their feeds, except the maximum number of changes in feeds is bound by $wgFeedLimit.

Change-Id: I8fb00ccd7efdd962a8a42f0bce3eac5177e2cfbd

includes/specials/SpecialRecentchanges.php
includes/specials/SpecialRecentchangeslinked.php

index 14f9c8d..2984bc7 100644 (file)
@@ -480,7 +480,12 @@ class SpecialRecentChanges extends IncludableSpecialPage {
                }
 
                // And now for the content
-               $this->getOutput()->setFeedAppendQuery( $this->getFeedQuery() );
+               $feedQuery = $this->getFeedQuery();
+               if ( $feedQuery !== '' ) {
+                       $this->getOutput()->setFeedAppendQuery( $feedQuery );
+               } else {
+                       $this->getOutput()->setFeedAppendQuery( false );
+               }
 
                if( $wgAllowCategorizedRecentChanges ) {
                        $this->filterByCategories( $rows, $opts );
@@ -533,11 +538,24 @@ class SpecialRecentChanges extends IncludableSpecialPage {
 
        /**
         * Get the query string to append to feed link URLs.
-        * This is overridden by RCL to add the target parameter
-        * @return bool
+        * 
+        * @return string
         */
        public function getFeedQuery() {
-               return false;
+               global $wgFeedLimit;
+
+               $this->getOptions()->validateIntBounds( 'limit', 0, $wgFeedLimit );
+               $options = $this->getOptions()->getChangedValues();
+
+               // wfArrayToCgi() omits options set to null or false
+               foreach ( $options as &$value ) {
+                       if ( $value === false ) {
+                               $value = '0';
+                       }
+               }
+               unset( $value );
+
+               return wfArrayToCgi( $options );
        }
 
        /**
index 4db8958..67a8609 100644 (file)
@@ -261,15 +261,6 @@ class SpecialRecentchangeslinked extends SpecialRecentChanges {
                }
        }
 
-       public function getFeedQuery() {
-               $target = $this->getTargetTitle();
-               if( $target ) {
-                       return "target=" . urlencode( $target->getPrefixedDBkey() );
-               } else {
-                       return false;
-               }
-       }
-
        function setBottomText( FormOptions $opts ) {
                if( isset( $this->mResultEmpty ) && $this->mResultEmpty ) {
                        $this->getOutput()->addWikiMsg( 'recentchangeslinked-noresult' );