Special:RC 'hidemajor' filter
authorStephane Bisson <sbisson@wikimedia.org>
Tue, 8 Nov 2016 20:36:46 +0000 (15:36 -0500)
committerStephane Bisson <sbisson@wikimedia.org>
Wed, 7 Dec 2016 12:06:26 +0000 (07:06 -0500)
'hidemajor', along with the existing 'hideminor'
RC filter, allow showing just the minor edits,
just the major edits, or both.

This will be used by the ERI project.

Bug: T149863
Change-Id: I936a4a1b13d8c4a15c745012cd0f82207d9e57ca

includes/specialpage/ChangesListSpecialPage.php
tests/phpunit/includes/specials/SpecialRecentchangesTest.php

index 2051948..00efeae 100644 (file)
@@ -140,6 +140,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                $opts = new FormOptions();
 
                $opts->add( 'hideminor', false );
+               $opts->add( 'hidemajor', false );
                $opts->add( 'hidebots', false );
                $opts->add( 'hidehumans', false );
                $opts->add( 'hideanons', false );
@@ -235,7 +236,10 @@ abstract class ChangesListSpecialPage extends SpecialPage {
 
                // Toggles
                if ( $opts['hideminor'] ) {
-                       $conds['rc_minor'] = 0;
+                       $conds[] = 'rc_minor = 0';
+               }
+               if ( $opts['hidemajor'] ) {
+                       $conds[] = 'rc_minor = 1';
                }
                if ( $opts['hidebots'] ) {
                        $conds['rc_bot'] = 0;
index 03e9c8f..c11e6a3 100644 (file)
@@ -55,13 +55,15 @@ class SpecialRecentchangesTest extends MediaWikiTestCase {
        }
 
        private static function normalizeCondition( $conds ) {
-               return array_map(
+               $normalized = array_map(
                        function ( $k, $v ) {
                                return is_numeric( $k ) ? $v : "$k = $v";
                        },
                        array_keys( $conds ),
                        $conds
                );
+               sort( $normalized );
+               return $normalized;
        }
 
        /** return false if condition begin with 'rc_timestamp ' */
@@ -343,6 +345,34 @@ class SpecialRecentchangesTest extends MediaWikiTestCase {
                );
        }
 
+       public function testRcHideminorFilter() {
+               $this->assertConditions(
+                       [ # expected
+                               'rc_bot' => 0,
+                               "rc_minor = 0",
+                               "rc_type != '6'",
+                       ],
+                       [
+                               'hideminor' => 1,
+                       ],
+                       "rc conditions: hideminor=1"
+               );
+       }
+
+       public function testRcHidemajorFilter() {
+               $this->assertConditions(
+                       [ # expected
+                               'rc_bot' => 0,
+                               "rc_minor = 1",
+                               "rc_type != '6'",
+                       ],
+                       [
+                               'hidemajor' => 1,
+                       ],
+                       "rc conditions: hidemajor=1"
+               );
+       }
+
        // This is probably going to change when we do auto-fix of
        // filters combinations that don't make sense but for now
        // it's the behavior therefore it's the test.