Correctly use $wgFeedLimit in page history feed
authorMatmaRex <matma.rex@gmail.com>
Sun, 7 Jul 2013 18:39:53 +0000 (20:39 +0200)
committerMatmaRex <matma.rex@gmail.com>
Sun, 7 Jul 2013 18:39:53 +0000 (20:39 +0200)
The previous behavior enforced a minimal maximum of 10, even if
$wgFeedLimit was set to a lower value.

Also grepped everything for $wgFeedLimit and fixed all other
error-prone (but correct) uses.

Bug: 50886
Change-Id: Ia81bbadfcf4270b0f932b543265ca37f364530f3

includes/QueryPage.php
includes/actions/HistoryAction.php
includes/api/ApiFeedWatchlist.php

index a93639a..0abeb31 100644 (file)
@@ -655,17 +655,14 @@ abstract class QueryPage extends SpecialPage {
         * @return bool
         */
        function doFeed( $class = '', $limit = 50 ) {
-               global $wgFeed, $wgFeedClasses;
+               global $wgFeed, $wgFeedClasses, $wgFeedLimit;
 
                if ( !$wgFeed ) {
                        $this->getOutput()->addWikiMsg( 'feed-unavailable' );
                        return false;
                }
 
-               global $wgFeedLimit;
-               if ( $limit > $wgFeedLimit ) {
-                       $limit = $wgFeedLimit;
-               }
+               $limit = min( $limit, $wgFeedLimit );
 
                if ( isset( $wgFeedClasses[$class] ) ) {
                        $feed = new $wgFeedClasses[$class](
index f43736b..bdb63d1 100644 (file)
@@ -262,9 +262,8 @@ class HistoryAction extends FormlessAction {
                // Get a limit on number of feed entries. Provide a sane default
                // of 10 if none is defined (but limit to $wgFeedLimit max)
                $limit = $request->getInt( 'limit', 10 );
-               if ( $limit > $wgFeedLimit || $limit < 1 ) {
-                       $limit = 10;
-               }
+               $limit = min( max( $limit, 1 ), $wgFeedLimit );
+
                $items = $this->fetchRevisions( $limit, 0, HistoryPage::DIR_NEXT );
 
                // Generate feed elements enclosed between header and footer.
index 9f6b8b4..fbb70fb 100644 (file)
@@ -76,7 +76,7 @@ class ApiFeedWatchlist extends ApiBase {
                                'wlprop' => 'title|user|comment|timestamp',
                                'wldir' => 'older', // reverse order - from newest to oldest
                                'wlend' => $endTime, // stop at this time
-                               'wllimit' => ( 50 > $wgFeedLimit ) ? $wgFeedLimit : 50
+                               'wllimit' => min( 50, $wgFeedLimit )
                        );
 
                        if ( $params['wlowner'] !== null ) {