]
],
+ [
+ 'name' => 'lastRevision',
+ 'title' => 'rcfilters-filtergroup-lastRevision',
+ 'class' => ChangesListBooleanFilterGroup::class,
+ 'priority' => -7,
+ 'filters' => [
+ [
+ '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_this_oldid <> page_latest';
+ },
+ 'cssClassSuffix' => 'last',
+ 'isRowApplicableCallable' => function ( $ctx, $rc ) {
+ return $rc->getAttribute( 'rc_this_oldid' ) === $rc->getAttribute( 'page_latest' );
+ }
+ ],
+ [
+ '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_this_oldid = page_latest';
+ },
+ 'cssClassSuffix' => 'previous',
+ 'isRowApplicableCallable' => function ( $ctx, $rc ) {
+ return $rc->getAttribute( 'rc_this_oldid' ) !== $rc->getAttribute( 'page_latest' );
+ }
+ ]
+ ]
+ ],
+
// With extensions, there can be change types that will not be hidden by any of these.
[
'name' => 'changeType',
'title' => 'rcfilters-filtergroup-changetype',
'class' => ChangesListBooleanFilterGroup::class,
+ 'priority' => -8,
'filters' => [
[
'name' => 'hidepageedits',
],
],
],
+
];
$this->reviewStatusFilterGroupDefinition = [
// Make sure this is not being transcluded (we don't want to show this
// information to all users just because the user that saves the edit can
- // patrol)
+ // patrol or is logged in)
if ( !$this->including() && $this->getUser()->useRCPatrol() ) {
$this->registerFiltersFromDefinitions( $this->reviewStatusFilterGroupDefinition );
}
}
}
- $opts->add( 'namespace', '', FormOptions::INTNULL );
+ $opts->add( 'namespace', '', FormOptions::STRING );
$opts->add( 'invert', false );
$opts->add( 'associated', false );
}
// Namespace filtering
- if ( $opts['namespace'] !== '' ) {
- $selectedNS = $dbr->addQuotes( $opts['namespace'] );
- $operator = $opts['invert'] ? '!=' : '=';
- $boolean = $opts['invert'] ? 'AND' : 'OR';
-
- // Namespace association (T4429)
- if ( !$opts['associated'] ) {
- $condition = "rc_namespace $operator $selectedNS";
- } else {
- // Also add the associated namespace
- $associatedNS = $dbr->addQuotes(
- MWNamespace::getAssociated( $opts['namespace'] )
+ if ( $opts[ 'namespace' ] !== '' ) {
+ $namespaces = explode( ',', $opts[ 'namespace' ] );
+
+ if ( $opts[ 'associated' ] ) {
+ $associatedNamespaces = array_map(
+ function ( $ns ) {
+ return MWNamespace::getAssociated( $ns );
+ },
+ $namespaces
);
- $condition = "(rc_namespace $operator $selectedNS "
- . $boolean
- . " rc_namespace $operator $associatedNS)";
+ $namespaces = array_unique( array_merge( $namespaces, $associatedNamespaces ) );
}
- $conds[] = $condition;
+ if ( count( $namespaces ) === 1 ) {
+ $operator = $opts[ 'invert' ] ? '!=' : '=';
+ $value = $dbr->addQuotes( reset( $namespaces ) );
+ } else {
+ $operator = $opts[ 'invert' ] ? 'NOT IN' : 'IN';
+ sort( $namespaces );
+ $value = '(' . $dbr->makeList( $namespaces ) . ')';
+ }
+ $conds[] = "rc_namespace $operator $value";
}
}
* @param array $selectedExpLevels The allowed active values, sorted
*/
public function filterOnUserExperienceLevel( $specialPageClassName, $context, $dbr,
- &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedExpLevels ) {
+ &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedExpLevels, $now = 0 ) {
global $wgLearnerEdits,
$wgExperiencedUserEdits,
$tables[] = 'user';
$join_conds['user'] = [ 'LEFT JOIN', 'rc_user = user_id' ];
- $now = time();
+ if ( $now === 0 ) {
+ $now = time();
+ }
$secondsPerDay = 86400;
$learnerCutoff = $now - $wgLearnerMemberSince * $secondsPerDay;
$experiencedUserCutoff = $now - $wgExperiencedUserMemberSince * $secondsPerDay;