Sbisson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/324784

Change subject: Special:RC filter: hideNonPatrolled
......................................................................

Special:RC filter: hideNonPatrolled

Allows hiding edits that have not been patrolled.
In other words, showing only edits that have been patrolled.

Will be used by the new Special:RC filters (ERI project).

Bug: T152061
Change-Id: I3cd896812c5af87bc4be53d493055c37298c712f
---
M includes/specialpage/ChangesListSpecialPage.php
M tests/phpunit/includes/specials/SpecialRecentchangesTest.php
2 files changed, 90 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/84/324784/1

diff --git a/includes/specialpage/ChangesListSpecialPage.php 
b/includes/specialpage/ChangesListSpecialPage.php
index cb13840..11ed19a 100644
--- a/includes/specialpage/ChangesListSpecialPage.php
+++ b/includes/specialpage/ChangesListSpecialPage.php
@@ -144,6 +144,7 @@
                $opts->add( 'hideanons', false );
                $opts->add( 'hideliu', false );
                $opts->add( 'hidepatrolled', false );
+               $opts->add( 'hidenonpatrolled', false );
                $opts->add( 'hidemyself', false );
                $opts->add( 'hidebyothers', false );
 
@@ -235,8 +236,13 @@
                if ( $opts['hidebots'] ) {
                        $conds['rc_bot'] = 0;
                }
-               if ( $user->useRCPatrol() && $opts['hidepatrolled'] ) {
-                       $conds['rc_patrolled'] = 0;
+               if ( $user->useRCPatrol() ) {
+                       if ( $opts['hidepatrolled'] ) {
+                               $conds[] = 'rc_patrolled = 0';
+                       }
+                       if ( $opts['hidenonpatrolled'] ) {
+                               $conds[] = 'rc_patrolled = 1';
+                       }
                }
                if ( $botsonly ) {
                        $conds['rc_bot'] = 1;
diff --git a/tests/phpunit/includes/specials/SpecialRecentchangesTest.php 
b/tests/phpunit/includes/specials/SpecialRecentchangesTest.php
index c51217c..3695297 100644
--- a/tests/phpunit/includes/specials/SpecialRecentchangesTest.php
+++ b/tests/phpunit/includes/specials/SpecialRecentchangesTest.php
@@ -215,4 +215,86 @@
                        $user
                );
        }
+
+       public function testRcHidepatrolledDisabledFilter() {
+               $user = $this->getTestUser()->getUser();
+               $this->assertConditions(
+                       [ # expected
+                               'rc_bot' => 0,
+                               0 => "rc_type != '6'",
+                       ],
+                       [
+                               'hidepatrolled' => 1,
+                       ],
+                       "rc conditions: hidepatrolled=1",
+                       $user
+               );
+       }
+
+       public function testRcHidenonpatrolledDisabledFilter() {
+               $user = $this->getTestUser()->getUser();
+               $this->assertConditions(
+                       [ # expected
+                               'rc_bot' => 0,
+                               0 => "rc_type != '6'",
+                       ],
+                       [
+                               'hidenonpatrolled' => 1,
+                       ],
+                       "rc conditions: hidepatrolled=1",
+                       $user
+               );
+       }
+       public function testRcHidepatrolledFilter() {
+               $user = $this->getTestSysop()->getUser();
+               $this->assertConditions(
+                       [ # expected
+                               'rc_bot' => 0,
+                               0 => "rc_patrolled = 0",
+                               1 => "rc_type != '6'",
+                       ],
+                       [
+                               'hidepatrolled' => 1,
+                       ],
+                       "rc conditions: hidepatrolled=1",
+                       $user
+               );
+       }
+
+       public function testRcHidenonpatrolledFilter() {
+               $user = $this->getTestSysop()->getUser();
+               $this->assertConditions(
+                       [ # expected
+                               'rc_bot' => 0,
+                               0 => "rc_patrolled = 1",
+                               1 => "rc_type != '6'",
+                       ],
+                       [
+                               'hidenonpatrolled' => 1,
+                       ],
+                       "rc conditions: hidepatrolled=1",
+                       $user
+               );
+       }
+
+       // 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.
+       public function testRcHidepatrolledHidenonpatrolledFilter() {
+               $user = $this->getTestSysop()->getUser();
+               $this->assertConditions(
+                       [ # expected
+                               'rc_bot' => 0,
+                               0 => "rc_patrolled = 0",
+                               1 => "rc_patrolled = 1",
+                               2 => "rc_type != '6'",
+                       ],
+                       [
+                               'hidepatrolled' => 1,
+                               'hidenonpatrolled' => 1,
+                       ],
+                       "rc conditions: hidepatrolled=1",
+                       $user
+               );
+       }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/324784
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3cd896812c5af87bc4be53d493055c37298c712f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Sbisson <sbis...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to