ChangesListSpecialPage: Stop mutating $opts in buildMainQueryConds()
authorBartosz Dziewoński <matma.rex@gmail.com>
Fri, 3 Jan 2014 15:48:06 +0000 (16:48 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Wed, 29 Jan 2014 16:56:21 +0000 (17:56 +0100)
Change-Id: I25bd15c3018e56ede05a529e38e577d6744c103e

includes/specialpage/ChangesListSpecialPage.php
includes/specials/SpecialRecentchanges.php

index 03bc8c2..4e2556c 100644 (file)
@@ -192,7 +192,6 @@ abstract class ChangesListSpecialPage extends SpecialPage {
 
        /**
         * Return an array of conditions depending of options set in $opts
-        * @todo Whyyyy is this mutating $opts…
         *
         * @param FormOptions $opts
         * @return array
@@ -202,15 +201,15 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                $user = $this->getUser();
                $conds = array();
 
-               // It makes no sense to hide both anons and logged-in users
-               // Where this occurs, force anons to be shown
-               $botsOnly = false;
+               // It makes no sense to hide both anons and logged-in users. When this occurs, try a guess on
+               // what the user meant and either show only bots or force anons to be shown.
+               $botsonly = false;
+               $hideanons = $opts['hideanons'];
                if ( $opts['hideanons'] && $opts['hideliu'] ) {
-                       // Check if the user wants to show bots only
                        if ( $opts['hidebots'] ) {
-                               $opts['hideanons'] = false;
+                               $hideanons = false;
                        } else {
-                               $botsOnly = true;
+                               $botsonly = true;
                        }
                }
 
@@ -224,13 +223,13 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                if ( $user->useRCPatrol() && $opts['hidepatrolled'] ) {
                        $conds['rc_patrolled'] = 0;
                }
-               if ( $botsOnly ) {
+               if ( $botsonly ) {
                        $conds['rc_bot'] = 1;
                } else {
                        if ( $opts['hideliu'] ) {
                                $conds[] = 'rc_user = 0';
                        }
-                       if ( $opts['hideanons'] ) {
+                       if ( $hideanons ) {
                                $conds[] = 'rc_user != 0';
                        }
                }
index 07da6d9..7352de7 100644 (file)
@@ -144,11 +144,11 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
        public function validateOptions( FormOptions $opts ) {
                global $wgFeedLimit;
                $opts->validateIntBounds( 'limit', 0, $this->feedFormat ? $wgFeedLimit : 5000 );
+               parent::validateOptions( $opts );
        }
 
        /**
         * Return an array of conditions depending of options set in $opts
-        * @todo Whyyyy is this mutating $opts…
         *
         * @param FormOptions $opts
         * @return array