// reviewStatus (conditional)
[
- 'name' => 'lastRevision',
- 'title' => 'rcfilters-filtergroup-lastRevision',
+ 'name' => 'significance',
+ 'title' => 'rcfilters-filtergroup-significance',
'class' => ChangesListBooleanFilterGroup::class,
- 'priority' => -7,
+ 'priority' => -6,
'filters' => [
[
- 'name' => 'hidelastrevision',
- 'label' => 'rcfilters-filter-lastrevision-label',
- 'description' => 'rcfilters-filter-lastrevision-description',
+ 'name' => 'hideminor',
+ 'label' => 'rcfilters-filter-minor-label',
+ 'description' => 'rcfilters-filter-minor-description',
+ // rcshowhideminor-show, rcshowhideminor-hide,
+ // wlshowhideminor
+ 'showHideSuffix' => 'showhideminor',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
&$query_options, &$join_conds ) {
- $conds[] = 'rc_this_oldid <> page_latest';
+
+ $conds[] = 'rc_minor = 0';
},
- 'cssClassSuffix' => 'last',
+ 'cssClassSuffix' => 'minor',
'isRowApplicableCallable' => function ( $ctx, $rc ) {
- return $rc->getAttribute( 'rc_this_oldid' ) === $rc->getAttribute( 'page_latest' );
+ return $rc->getAttribute( 'rc_minor' );
}
],
[
- 'name' => 'hidepreviousrevisions',
- 'label' => 'rcfilters-filter-previousrevision-label',
- 'description' => 'rcfilters-filter-previousrevision-description',
+ 'name' => 'hidemajor',
+ 'label' => 'rcfilters-filter-major-label',
+ 'description' => 'rcfilters-filter-major-description',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
&$query_options, &$join_conds ) {
- $conds[] = 'rc_this_oldid = page_latest';
+
+ $conds[] = 'rc_minor = 1';
},
- 'cssClassSuffix' => 'previous',
+ 'cssClassSuffix' => 'major',
'isRowApplicableCallable' => function ( $ctx, $rc ) {
- return $rc->getAttribute( 'rc_this_oldid' ) !== $rc->getAttribute( 'page_latest' );
+ return !$rc->getAttribute( 'rc_minor' );
}
]
]
],
[
- 'name' => 'significance',
- 'title' => 'rcfilters-filtergroup-significance',
+ 'name' => 'lastRevision',
+ 'title' => 'rcfilters-filtergroup-lastRevision',
'class' => ChangesListBooleanFilterGroup::class,
- 'priority' => -6,
+ 'priority' => -7,
'filters' => [
[
- 'name' => 'hideminor',
- 'label' => 'rcfilters-filter-minor-label',
- 'description' => 'rcfilters-filter-minor-description',
- // rcshowhideminor-show, rcshowhideminor-hide,
- // wlshowhideminor
- 'showHideSuffix' => 'showhideminor',
+ 'name' => 'hidelastrevision',
+ 'label' => 'rcfilters-filter-lastrevision-label',
+ 'description' => 'rcfilters-filter-lastrevision-description',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
&$query_options, &$join_conds ) {
-
- $conds[] = 'rc_minor = 0';
+ $conds[] = 'rc_this_oldid <> page_latest';
},
- 'cssClassSuffix' => 'minor',
+ 'cssClassSuffix' => 'last',
'isRowApplicableCallable' => function ( $ctx, $rc ) {
- return $rc->getAttribute( 'rc_minor' );
+ return $rc->getAttribute( 'rc_this_oldid' ) === $rc->getAttribute( 'page_latest' );
}
],
[
- 'name' => 'hidemajor',
- 'label' => 'rcfilters-filter-major-label',
- 'description' => 'rcfilters-filter-major-description',
+ 'name' => 'hidepreviousrevisions',
+ 'label' => 'rcfilters-filter-previousrevision-label',
+ 'description' => 'rcfilters-filter-previousrevision-description',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
&$query_options, &$join_conds ) {
-
- $conds[] = 'rc_minor = 1';
+ $conds[] = 'rc_this_oldid = page_latest';
},
- 'cssClassSuffix' => 'major',
+ 'cssClassSuffix' => 'previous',
'isRowApplicableCallable' => function ( $ctx, $rc ) {
- return !$rc->getAttribute( 'rc_minor' );
+ return $rc->getAttribute( 'rc_this_oldid' ) !== $rc->getAttribute( 'page_latest' );
}
]
]
* @param FormOptions $opts
*/
public function validateOptions( FormOptions $opts ) {
- // nothing by default
+ if ( $this->fixContradictoryOptions( $opts ) ) {
+ $query = wfArrayToCgi( $this->convertParamsForLink( $opts->getChangedValues() ) );
+ $this->getOutput()->redirect( $this->getPageTitle()->getCanonicalURL( $query ) );
+ }
+ }
+
+ /**
+ * Fix invalid options by resetting pairs that should never appear together.
+ *
+ * @param FormOptions $opts
+ * @return bool True if any option was reset
+ */
+ private function fixContradictoryOptions( FormOptions $opts ) {
+ $contradictorySets = [];
+
+ $fixed = $this->fixBackwardsCompatibilityOptions( $opts );
+
+ foreach ( $this->filterGroups as $filterGroup ) {
+ if ( $filterGroup instanceof ChangesListBooleanFilterGroup ) {
+ $filters = $filterGroup->getFilters();
+ $allInGroupEnabled = array_reduce(
+ $filters,
+ function ( $carry, $filter ) use ( $opts ) {
+ return $carry && $opts[ $filter->getName() ];
+ },
+ /* initialValue */ count( $filters ) > 0
+ );
+
+ if ( $allInGroupEnabled ) {
+ foreach ( $filters as $filter ) {
+ $opts->reset( $filter->getName() );
+ }
+
+ $fixed = true;
+ }
+ }
+ }
+
+ return $fixed;
+ }
+
+ /**
+ * Fix a special case (hideanons=1 and hideliu=1) in a special way, for backwards
+ * compatibility.
+ *
+ * This is deprecated and may be removed.
+ *
+ * @param FormOptions $opts
+ * @return bool True if this change was mode
+ */
+ private function fixBackwardsCompatibilityOptions( FormOptions $opts ) {
+ if ( $opts['hideanons'] && $opts['hideliu'] ) {
+ $opts->reset( 'hideanons' );
+ if ( !$opts['hidebots'] ) {
+ $opts->reset( 'hideliu' );
+ $opts['hidehumans'] = 1;
+ }
+
+ return true;
+ }
+
+ return false;
+
+ }
+
+ /**
+ * Convert parameters values from true/false to 1/0
+ * so they are not omitted by wfArrayToCgi()
+ * Bug 36524
+ *
+ * @param array $params
+ * @return array
+ */
+ protected function convertParamsForLink( $params ) {
+ foreach ( $params as &$value ) {
+ if ( $value === false ) {
+ $value = '0';
+ }
+ }
+ unset( $value );
+ return $params;
}
/**
''
);
- // It makes no sense to hide both anons and logged-in users. When this occurs, try a guess on
- // what the user meant and either show only bots or force anons to be shown.
-
- // -------
-
- // XXX: We're no longer doing this handling. To preserve back-compat, we need to complete
- // T151873 (particularly the hideanons/hideliu/hidebots/hidehumans part) in conjunction
- // with merging this.
-
if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
$opts )
) {