* @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 ) );
}
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()
[
[ '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,