RC Filters: Disable defaults for legacy filters in structured UI
authorStephane Bisson <sbisson@wikimedia.org>
Wed, 5 Apr 2017 13:50:50 +0000 (09:50 -0400)
committerStephane Bisson <sbisson@wikimedia.org>
Wed, 5 Apr 2017 14:03:40 +0000 (10:03 -0400)
Some legacy filters are replaced in structured UI by new filters.
It's important that their default value doesn't cause them
to filter the results when they are not even visible to the
user.

Bug: T162158
Change-Id: I3ff09164bbc0d14283302aa37bdee2c7ef9f5eb3

includes/changes/ChangesListBooleanFilter.php
includes/specialpage/ChangesListSpecialPage.php

index 4117a11..851d173 100644 (file)
@@ -136,10 +136,15 @@ class ChangesListBooleanFilter extends ChangesListFilter {
        }
 
        /**
+        * Get the default value
+        *
+        * @param bool $structuredUI Are we currently showing the structured UI
         * @return bool|null Default value
         */
-       public function getDefault() {
-               return $this->defaultValue;
+       public function getDefault( $structuredUI = false ) {
+               return $this->isReplacedInStructuredUi && $structuredUI ?
+                       false :
+                       $this->defaultValue;
        }
 
        /**
index ad9a248..d9472af 100644 (file)
@@ -707,6 +707,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
        public function getDefaultOptions() {
                $config = $this->getConfig();
                $opts = new FormOptions();
+               $structuredUI = $this->getUser()->getOption( 'rcenhancedfilters' );
 
                // Add all filters
                foreach ( $this->filterGroups as $filterGroup ) {
@@ -716,7 +717,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                                $opts->add( $filterGroup->getName(), $filterGroup->getDefault() );
                        } else {
                                foreach ( $filterGroup->getFilters() as $filter ) {
-                                       $opts->add( $filter->getName(), $filter->getDefault() );
+                                       $opts->add( $filter->getName(), $filter->getDefault( $structuredUI ) );
                                }
                        }
                }