From: petarpetkovic Date: Wed, 27 Sep 2017 14:00:18 +0000 (+0200) Subject: Migrate and convert WL settings to the new UX X-Git-Tag: 1.31.0-rc.0~1942^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_aide%28?a=commitdiff_plain;h=7df800cb0b8040ed7bdc15741ab6a2494e48e63d;p=lhc%2Fweb%2Fwiklou.git Migrate and convert WL settings to the new UX 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 --- diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index 8a474864f0..fcf1bfb8b9 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -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 diff --git a/tests/phpunit/includes/specials/SpecialWatchlistTest.php b/tests/phpunit/includes/specials/SpecialWatchlistTest.php index 1c43919955..a0fe33921f 100644 --- a/tests/phpunit/includes/specials/SpecialWatchlistTest.php +++ b/tests/phpunit/includes/specials/SpecialWatchlistTest.php @@ -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,