From afaab18b0863d1aceeb5337b5ee97c38769cecfa Mon Sep 17 00:00:00 2001 From: Stephane Bisson Date: Tue, 8 Nov 2016 15:36:46 -0500 Subject: [PATCH] Special:RC 'hidemajor' filter '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 --- .../specialpage/ChangesListSpecialPage.php | 6 +++- .../specials/SpecialRecentchangesTest.php | 32 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php index 205194881d..00efeae1e2 100644 --- a/includes/specialpage/ChangesListSpecialPage.php +++ b/includes/specialpage/ChangesListSpecialPage.php @@ -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; diff --git a/tests/phpunit/includes/specials/SpecialRecentchangesTest.php b/tests/phpunit/includes/specials/SpecialRecentchangesTest.php index 03e9c8fee0..c11e6a3927 100644 --- a/tests/phpunit/includes/specials/SpecialRecentchangesTest.php +++ b/tests/phpunit/includes/specials/SpecialRecentchangesTest.php @@ -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. -- 2.20.1