From 9cd114f3800e1f3e62a9bf6467f1881b0d781588 Mon Sep 17 00:00:00 2001 From: Stephane Bisson Date: Mon, 14 Nov 2016 14:17:42 -0500 Subject: [PATCH] Special:RC filters: hide page edits, new pages, log entries New RC filters for ERI project: hidepageedits hidenewpages hidelog Bug: T150060 Change-Id: I6fe852fb0f5386c3385ada5189ceaf0d9bbc979d --- .../specialpage/ChangesListSpecialPage.php | 12 ++++++ .../specials/SpecialRecentchangesTest.php | 42 +++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php index 9e3e3df399..c1c16854a0 100644 --- a/includes/specialpage/ChangesListSpecialPage.php +++ b/includes/specialpage/ChangesListSpecialPage.php @@ -150,6 +150,9 @@ abstract class ChangesListSpecialPage extends SpecialPage { if ( $config->get( 'RCWatchCategoryMembership' ) ) { $opts->add( 'hidecategorization', false ); } + $opts->add( 'hidepageedits', false ); + $opts->add( 'hidenewpages', false ); + $opts->add( 'hidelog', false ); $opts->add( 'namespace', '', FormOptions::INTNULL ); $opts->add( 'invert', false ); @@ -269,6 +272,15 @@ abstract class ChangesListSpecialPage extends SpecialPage { ) { $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_CATEGORIZE ); } + if ( $opts['hidepageedits'] ) { + $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_EDIT ); + } + if ( $opts['hidenewpages'] ) { + $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_NEW ); + } + if ( $opts['hidelog'] ) { + $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_LOG ); + } // Namespace filtering if ( $opts['namespace'] !== '' ) { diff --git a/tests/phpunit/includes/specials/SpecialRecentchangesTest.php b/tests/phpunit/includes/specials/SpecialRecentchangesTest.php index 6fb0d23589..388e2fd8a5 100644 --- a/tests/phpunit/includes/specials/SpecialRecentchangesTest.php +++ b/tests/phpunit/includes/specials/SpecialRecentchangesTest.php @@ -225,4 +225,46 @@ class SpecialRecentchangesTest extends MediaWikiTestCase { $user ); } + + public function testRcHidepageedits() { + $this->assertConditions( + [ # expected + 'rc_bot' => 0, + "rc_type != '6'", + "rc_type != '0'", + ], + [ + 'hidepageedits' => 1, + ], + "rc conditions: hidepageedits=1" + ); + } + + public function testRcHidenewpages() { + $this->assertConditions( + [ # expected + 'rc_bot' => 0, + "rc_type != '6'", + "rc_type != '1'", + ], + [ + 'hidenewpages' => 1, + ], + "rc conditions: hidenewpages=1" + ); + } + + public function testRcHidelog() { + $this->assertConditions( + [ # expected + 'rc_bot' => 0, + "rc_type != '6'", + "rc_type != '3'", + ], + [ + 'hidelog' => 1, + ], + "rc conditions: hidelog=1" + ); + } } -- 2.20.1