'showHideSuffix' => 'showhideliu',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$conds[] = 'rc_user = 0';
},
'cssClassSuffix' => 'liu',
'showHideSuffix' => 'showhideanons',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$conds[] = 'rc_user != 0';
},
'cssClassSuffix' => 'anon',
'showHideSuffix' => 'showhidemine',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$user = $ctx->getUser();
$conds[] = 'rc_user_text != ' . $dbr->addQuotes( $user->getName() );
},
'description' => 'rcfilters-filter-editsbyother-description',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$user = $ctx->getUser();
$conds[] = 'rc_user_text = ' . $dbr->addQuotes( $user->getName() );
},
'showHideSuffix' => 'showhidebots',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$conds[] = 'rc_bot = 0';
},
'cssClassSuffix' => 'bot',
'description' => 'rcfilters-filter-humans-description',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$conds[] = 'rc_bot = 1';
},
'cssClassSuffix' => 'human',
'showHideSuffix' => 'showhideminor',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$conds[] = 'rc_minor = 0';
},
'cssClassSuffix' => 'minor',
'description' => 'rcfilters-filter-major-description',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$conds[] = 'rc_minor = 1';
},
'cssClassSuffix' => 'major',
'default' => false,
'priority' => -2,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$conds[] = 'rc_type != ' . $dbr->addQuotes( RC_EDIT );
},
'cssClassSuffix' => 'src-mw-edit',
'default' => false,
'priority' => -3,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$conds[] = 'rc_type != ' . $dbr->addQuotes( RC_NEW );
},
'cssClassSuffix' => 'src-mw-new',
'default' => false,
'priority' => -5,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$conds[] = 'rc_type != ' . $dbr->addQuotes( RC_LOG );
},
'cssClassSuffix' => 'src-mw-log',
'showHideSuffix' => 'showhidepatr',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$conds[] = 'rc_patrolled = 0';
},
'cssClassSuffix' => 'patrolled',
'description' => 'rcfilters-filter-unpatrolled-description',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$conds[] = 'rc_patrolled = 1';
},
'cssClassSuffix' => 'unpatrolled',
'default' => false,
'priority' => -4,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
-
+ &$query_options, &$join_conds
+ ) {
$conds[] = 'rc_type != ' . $dbr->addQuotes( RC_CATEGORIZE );
},
'cssClassSuffix' => 'src-mw-categorize',
$opts = $this->getOptions();
/** @var ChangesListFilterGroup $group */
foreach ( $this->getFilterGroups() as $group ) {
-
if ( $group->getConflictingGroups() ) {
wfLogWarning(
$group->getName() .
/** @var ChangesListFilter $filter */
foreach ( $group->getFilters() as $filter ) {
-
/** @var ChangesListFilter $conflictingFilter */
foreach ( $filter->getConflictingFilters() as $conflictingFilter ) {
if (
$config = $this->getConfig();
$opts = new FormOptions();
$structuredUI = $this->getUser()->getOption( 'rcenhancedfilters' );
+ // If urlversion=2 is set, ignore the filter defaults and set them all to false/empty
+ $useDefaults = $this->getRequest()->getInt( 'urlversion' ) !== 2;
// Add all filters
foreach ( $this->filterGroups as $filterGroup ) {
// URL parameters can be per-group, like 'userExpLevel',
// or per-filter, like 'hideminor'.
if ( $filterGroup->isPerGroupRequestParameter() ) {
- $opts->add( $filterGroup->getName(), $filterGroup->getDefault() );
+ $opts->add( $filterGroup->getName(), $useDefaults ? $filterGroup->getDefault() : '' );
} else {
foreach ( $filterGroup->getFilters() as $filter ) {
- $opts->add( $filter->getName(), $filter->getDefault( $structuredUI ) );
+ $opts->add( $filter->getName(), $useDefaults ? $filter->getDefault( $structuredUI ) : false );
}
}
}
$opts->add( 'namespace', '', FormOptions::STRING );
$opts->add( 'invert', false );
$opts->add( 'associated', false );
+ $opts->add( 'urlversion', 1 );
return $opts;
}
* @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 ) {
+ $fixed = $this->fixBackwardsCompatibilityOptions( $opts );
+
+ foreach ( $this->filterGroups as $filterGroup ) {
+ if ( $filterGroup instanceof ChangesListBooleanFilterGroup ) {
+ $filters = $filterGroup->getFilters();
+
+ if ( count( $filters ) === 1 ) {
+ // legacy boolean filters should not be considered
+ continue;
+ }
+
+ $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[ $filter->getName() ] = false;
+ }
+
+ $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;
}
/**
* @param FormOptions $opts
*/
protected function buildQuery( &$tables, &$fields, &$conds, &$query_options,
- &$join_conds, FormOptions $opts ) {
-
+ &$join_conds, FormOptions $opts
+ ) {
$dbr = $this->getDB();
$user = $this->getUser();
// Namespace filtering
if ( $opts[ 'namespace' ] !== '' ) {
- $namespaces = explode( ',', $opts[ 'namespace' ] );
+ $namespaces = explode( ';', $opts[ 'namespace' ] );
if ( $opts[ 'associated' ] ) {
$associatedNamespaces = array_map(
* @return bool|ResultWrapper Result or false
*/
protected function doMainQuery( $tables, $fields, $conds,
- $query_options, $join_conds, FormOptions $opts ) {
-
+ $query_options, $join_conds, FormOptions $opts
+ ) {
$tables[] = 'recentchanges';
$fields = array_merge( RecentChange::selectFields(), $fields );
''
);
- // 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 )
) {
$legend .= Html::closeElement( 'dl' ) . "\n";
# Collapsibility
+ $legendHeading = $this->getUser()->getOption(
+ 'rcenhancedfilters'
+ ) ?
+ $context->msg( 'rcfilters-legend-heading' )->parse() :
+ $context->msg( 'recentchanges-legend-heading' )->parse();
$legend =
'<div class="mw-changeslist-legend">' .
- $context->msg( 'recentchanges-legend-heading' )->parse() .
+ $legendHeading .
'<div class="mw-collapsible-content">' . $legend . '</div>' .
'</div>';
* (optional)
*/
public function filterOnUserExperienceLevel( $specialPageClassName, $context, $dbr,
- &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedExpLevels, $now = 0 ) {
-
+ &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedExpLevels, $now = 0
+ ) {
global $wgLearnerEdits,
$wgExperiencedUserEdits,
$wgLearnerMemberSince,
$aboveNewcomer = $dbr->makeList(
[
'user_editcount >= ' . intval( $wgLearnerEdits ),
- 'user_registration <= ' . $dbr->timestamp( $learnerCutoff ),
+ 'user_registration <= ' . $dbr->addQuotes( $dbr->timestamp( $learnerCutoff ) ),
],
IDatabase::LIST_AND
);
$aboveLearner = $dbr->makeList(
[
'user_editcount >= ' . intval( $wgExperiencedUserEdits ),
- 'user_registration <= ' . $dbr->timestamp( $experiencedUserCutoff ),
+ 'user_registration <= ' .
+ $dbr->addQuotes( $dbr->timestamp( $experiencedUserCutoff ) ),
],
IDatabase::LIST_AND
);