RCFilters: Don't let new params filter out old page
authorStephane Bisson <sbisson@wikimedia.org>
Mon, 16 Oct 2017 11:09:55 +0000 (07:09 -0400)
committerStephane Bisson <sbisson@wikimedia.org>
Mon, 16 Oct 2017 19:56:37 +0000 (15:56 -0400)
Bug: T177884
Change-Id: Id0ace30b837cf6c5fa7159aa40d80392187c4e16

includes/changes/ChangesListStringOptionsFilterGroup.php
includes/specialpage/ChangesListSpecialPage.php
tests/phpunit/includes/specialpage/ChangesListSpecialPageTest.php

index 59efd82..2d1521d 100644 (file)
@@ -242,4 +242,14 @@ class ChangesListStringOptionsFilterGroup extends ChangesListFilterGroup {
 
                return $output;
        }
+
+       /**
+        * Check if this filter group is currently active
+        *
+        * @param {boolean} $isStructuredUI Is structured filters UI current enabled
+        */
+       public function isActive( $isStructuredUI ) {
+               // STRING_OPTIONS filter groups are exclusively active on Structured UI
+               return $isStructuredUI;
+       }
 }
index 20fd06a..3f45250 100644 (file)
@@ -1295,8 +1295,10 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                        // URL parameters can be per-group, like 'userExpLevel',
                        // or per-filter, like 'hideminor'.
                        if ( $filterGroup->isPerGroupRequestParameter() ) {
-                               $filterGroup->modifyQuery( $dbr, $this, $tables, $fields, $conds,
-                                       $query_options, $join_conds, $opts[$filterGroup->getName()] );
+                               if ( $filterGroup->isActive( $isStructuredUI ) ) {
+                                       $filterGroup->modifyQuery( $dbr, $this, $tables, $fields, $conds,
+                                               $query_options, $join_conds, $opts[$filterGroup->getName()] );
+                               }
                        } else {
                                foreach ( $filterGroup->getFilters() as $filter ) {
                                        if ( $filter->isActive( $opts, $isStructuredUI ) ) {
index d967588..5a0834a 100644 (file)
@@ -15,6 +15,13 @@ use Wikimedia\TestingAccessWrapper;
  * @covers ChangesListSpecialPage
  */
 class ChangesListSpecialPageTest extends AbstractChangesListSpecialPageTestCase {
+       public function setUp() {
+               parent::setUp();
+               $this->setMwGlobals( [
+                       'wgStructuredChangeFiltersShowPreference' => true,
+               ] );
+       }
+
        protected function getPage() {
                $mock = $this->getMockBuilder( ChangesListSpecialPage::class )
                        ->setConstructorArgs(