Merge "RCFilters: define consistent interface in ChangesListFilterGroup"
[lhc/web/wiklou.git] / includes / specialpage / ChangesListSpecialPage.php
index bd8c4b6..67f68ea 100644 (file)
@@ -1192,7 +1192,10 @@ abstract class ChangesListSpecialPage extends SpecialPage {
         * @param FormOptions $opts
         */
        public function validateOptions( FormOptions $opts ) {
         * @param FormOptions $opts
         */
        public function validateOptions( FormOptions $opts ) {
-               if ( $this->fixContradictoryOptions( $opts ) ) {
+               $isContradictory = $this->fixContradictoryOptions( $opts );
+               $isReplaced = $this->replaceOldOptions( $opts );
+
+               if ( $isContradictory || $isReplaced ) {
                        $query = wfArrayToCgi( $this->convertParamsForLink( $opts->getChangedValues() ) );
                        $this->getOutput()->redirect( $this->getPageTitle()->getCanonicalURL( $query ) );
                }
                        $query = wfArrayToCgi( $this->convertParamsForLink( $opts->getChangedValues() ) );
                        $this->getOutput()->redirect( $this->getPageTitle()->getCanonicalURL( $query ) );
                }
@@ -1263,6 +1266,34 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                return false;
        }
 
                return false;
        }
 
+       /**
+        * Replace old options 'hideanons' or 'hideliu' with structured UI equivalent
+        *
+        * @param FormOptions $opts
+        * @return bool True if the change was made
+        */
+       public function replaceOldOptions( FormOptions $opts ) {
+               if ( !$this->isStructuredFilterUiEnabled() ) {
+                       return false;
+               }
+
+               // At this point 'hideanons' and 'hideliu' cannot be both true,
+               // because fixBackwardsCompatibilityOptions resets (at least) 'hideanons' in such case
+               if ( $opts[ 'hideanons' ] ) {
+                       $opts->reset( 'hideanons' );
+                       $opts[ 'userExpLevel' ] = 'registered';
+                       return true;
+               }
+
+               if ( $opts[ 'hideliu' ] ) {
+                       $opts->reset( 'hideliu' );
+                       $opts[ 'userExpLevel' ] = 'unregistered';
+                       return true;
+               }
+
+               return false;
+       }
+
        /**
         * Convert parameters values from true/false to 1/0
         * so they are not omitted by wfArrayToCgi()
        /**
         * Convert parameters values from true/false to 1/0
         * so they are not omitted by wfArrayToCgi()