From: petarpetkovic Date: Tue, 17 Oct 2017 13:22:46 +0000 (+0200) Subject: Replace deprecated edit review params X-Git-Tag: 1.31.0-rc.0~1729 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_aide%28?a=commitdiff_plain;h=b5df5477cc4c937abdc46b82dcc164616ed474f1;p=lhc%2Fweb%2Fwiklou.git Replace deprecated edit review params - Replace old options 'hideanons' or 'hideliu' with structured UI equivalent. - Update tests to take this new behavior into account. Bug: T176172 Change-Id: I6ad050f7864bf51db05c3db957ac3533358cd3ac --- diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php index 3f45250508..418ef05758 100644 --- a/includes/specialpage/ChangesListSpecialPage.php +++ b/includes/specialpage/ChangesListSpecialPage.php @@ -1185,7 +1185,10 @@ abstract class ChangesListSpecialPage extends SpecialPage { * @param FormOptions $opts */ public function validateOptions( FormOptions $opts ) { - if ( $this->fixContradictoryOptions( $opts ) ) { + $isContradictory = $this->fixContradictoryOptions( $opts ); + $isReplaced = $this->replaceOldOptions( $opts ); + + if ( $isContradictory || $isReplaced ) { $query = wfArrayToCgi( $this->convertParamsForLink( $opts->getChangedValues() ) ); $this->getOutput()->redirect( $this->getPageTitle()->getCanonicalURL( $query ) ); } @@ -1256,6 +1259,34 @@ abstract class ChangesListSpecialPage extends SpecialPage { return false; } + /** + * Replace old options 'hideanons' or 'hideliu' with structured UI equivalent + * + * @param FormOptions $opts + * @return bool True if the change was made + */ + public function replaceOldOptions( FormOptions $opts ) { + if ( !$this->isStructuredFilterUiEnabled() ) { + return false; + } + + // At this point 'hideanons' and 'hideliu' cannot be both true, + // because fixBackwardsCompatibilityOptions resets (at least) 'hideanons' in such case + if ( $opts[ 'hideanons' ] ) { + $opts->reset( 'hideanons' ); + $opts[ 'userExpLevel' ] = 'registered'; + return true; + } + + if ( $opts[ 'hideliu' ] ) { + $opts->reset( 'hideliu' ); + $opts[ 'userExpLevel' ] = 'unregistered'; + return true; + } + + return false; + } + /** * Convert parameters values from true/false to 1/0 * so they are not omitted by wfArrayToCgi() diff --git a/tests/phpunit/includes/specialpage/ChangesListSpecialPageTest.php b/tests/phpunit/includes/specialpage/ChangesListSpecialPageTest.php index 5a0834a651..9b81d6d77d 100644 --- a/tests/phpunit/includes/specialpage/ChangesListSpecialPageTest.php +++ b/tests/phpunit/includes/specialpage/ChangesListSpecialPageTest.php @@ -981,15 +981,33 @@ class ChangesListSpecialPageTest extends AbstractChangesListSpecialPageTestCase [ [ 'hideanons' => 1, 'hideliu' => 1, 'hidebots' => 1 ], true, - [ 'hideliu' => 1, 'hidebots' => 1, ], + [ 'userExpLevel' => 'unregistered', 'hidebots' => 1, ], ], - [ [ 'hideanons' => 1, 'hideliu' => 1, 'hidebots' => 0 ], true, [ 'hidebots' => 0, 'hidehumans' => 1 ], ], - + [ + [ 'hideanons' => 1 ], + true, + [ 'userExpLevel' => 'registered' ] + ], + [ + [ 'hideliu' => 1 ], + true, + [ 'userExpLevel' => 'unregistered' ] + ], + [ + [ 'hideanons' => 1, 'hidebots' => 1 ], + true, + [ 'userExpLevel' => 'registered', 'hidebots' => 1 ] + ], + [ + [ 'hideliu' => 1, 'hidebots' => 0 ], + true, + [ 'userExpLevel' => 'unregistered', 'hidebots' => 0 ] + ], [ [ 'hidemyself' => 1, 'hidebyothers' => 1 ], true,