$opts = new FormOptions();
$opts->add( 'hideminor', false );
+ $opts->add( 'hidemajor', false );
$opts->add( 'hidebots', false );
$opts->add( 'hidehumans', false );
$opts->add( 'hideanons', false );
// Toggles
if ( $opts['hideminor'] ) {
- $conds['rc_minor'] = 0;
+ $conds[] = 'rc_minor = 0';
+ }
+ if ( $opts['hidemajor'] ) {
+ $conds[] = 'rc_minor = 1';
}
if ( $opts['hidebots'] ) {
$conds['rc_bot'] = 0;
}
private static function normalizeCondition( $conds ) {
- return array_map(
+ $normalized = array_map(
function ( $k, $v ) {
return is_numeric( $k ) ? $v : "$k = $v";
},
array_keys( $conds ),
$conds
);
+ sort( $normalized );
+ return $normalized;
}
/** return false if condition begin with 'rc_timestamp ' */
);
}
+ public function testRcHideminorFilter() {
+ $this->assertConditions(
+ [ # expected
+ 'rc_bot' => 0,
+ "rc_minor = 0",
+ "rc_type != '6'",
+ ],
+ [
+ 'hideminor' => 1,
+ ],
+ "rc conditions: hideminor=1"
+ );
+ }
+
+ public function testRcHidemajorFilter() {
+ $this->assertConditions(
+ [ # expected
+ 'rc_bot' => 0,
+ "rc_minor = 1",
+ "rc_type != '6'",
+ ],
+ [
+ 'hidemajor' => 1,
+ ],
+ "rc conditions: hidemajor=1"
+ );
+ }
+
// This is probably going to change when we do auto-fix of
// filters combinations that don't make sense but for now
// it's the behavior therefore it's the test.