Migrate and convert WL settings to the new UX
authorpetarpetkovic <ppetkovic@wikimedia.org>
Wed, 27 Sep 2017 14:00:18 +0000 (16:00 +0200)
committerpetarpetkovic <ppetkovic@wikimedia.org>
Wed, 27 Sep 2017 19:15:12 +0000 (21:15 +0200)
Convert Watchlist settings to new UX, with following rules:
- If "Hide edits by anonymous users from the watchlist" is checked,
add "Registered" filter to defaults.
- If "Hide edits by logged in users from the watchlist" is checked,
add "Unregistered" filter to defaults.
- Change test for Special:Watchlist page, so new structured filters
are supported.

Bug: T172757
Change-Id: I27bdaa1401323fa3143f79a57dc5b9773e48fd1d

includes/specials/SpecialWatchlist.php
tests/phpunit/includes/specials/SpecialWatchlistTest.php

index 8a47486..fcf1bfb 100644 (file)
@@ -248,6 +248,22 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                $hideLiu = $registration->getFilter( 'hideliu' );
                $hideLiu->setDefault( $user->getBoolOption( 'watchlisthideliu' ) );
 
+               // Selecting both hideanons and hideliu on watchlist preferances
+               // gives mutually exclusive filters, so those are ignored
+               if ( $user->getBoolOption( 'watchlisthideanons' ) &&
+                       !$user->getBoolOption( 'watchlisthideliu' )
+               ) {
+                       $this->getFilterGroup( 'userExpLevel' )
+                               ->setDefault( 'registered' );
+               }
+
+               if ( $user->getBoolOption( 'watchlisthideliu' ) &&
+                       !$user->getBoolOption( 'watchlisthideanons' )
+               ) {
+                       $this->getFilterGroup( 'userExpLevel' )
+                               ->setDefault( 'unregistered' );
+               }
+
                $reviewStatus = $this->getFilterGroup( 'reviewStatus' );
                if ( $reviewStatus !== null ) {
                        // Conditional on feature being available and rights
index 1c43919..a0fe339 100644 (file)
@@ -149,6 +149,7 @@ class SpecialWatchlistTest extends SpecialPageTestBase {
                                        // Second two overriden
                                        'hideanons' => false,
                                        'hideliu' => true,
+                                       'userExpLevel' => 'registered'
                                ] + $wikiDefaults,
                                [
                                        'watchlisthideminor' => 1,
@@ -171,12 +172,14 @@ class SpecialWatchlistTest extends SpecialPageTestBase {
                                        'hidebots' => true,
                                        'hideanons' => false,
                                        'hideliu' => true,
+                                       'userExpLevel' => 'unregistered'
                                ] + $allFalse,
                                [
                                        'watchlisthideminor' => 0,
                                        'watchlisthidebots' => 1,
-                                       'watchlisthideanons' => 1,
-                                       'watchlisthideliu' => 0,
+
+                                       'watchlisthideanons' => 0,
+                                       'watchlisthideliu' => 1,
                                ],
                                [
                                        'hidebots' => 1,