Code Duplication    Length = 5-6 lines in 5 locations

includes/WatchedItemQueryService.php 5 locations

@@ 438-442 (lines=5) @@
435
	private function getWatchedItemsWithRCInfoQueryFilterConds( User $user, array $options ) {
436
		$conds = [];
437
438
		if ( in_array( self::FILTER_MINOR, $options['filters'] ) ) {
439
			$conds[] = 'rc_minor != 0';
440
		} elseif ( in_array( self::FILTER_NOT_MINOR, $options['filters'] ) ) {
441
			$conds[] = 'rc_minor = 0';
442
		}
443
444
		if ( in_array( self::FILTER_BOT, $options['filters'] ) ) {
445
			$conds[] = 'rc_bot != 0';
@@ 444-448 (lines=5) @@
441
			$conds[] = 'rc_minor = 0';
442
		}
443
444
		if ( in_array( self::FILTER_BOT, $options['filters'] ) ) {
445
			$conds[] = 'rc_bot != 0';
446
		} elseif ( in_array( self::FILTER_NOT_BOT, $options['filters'] ) ) {
447
			$conds[] = 'rc_bot = 0';
448
		}
449
450
		if ( in_array( self::FILTER_ANON, $options['filters'] ) ) {
451
			$conds[] = 'rc_user = 0';
@@ 450-454 (lines=5) @@
447
			$conds[] = 'rc_bot = 0';
448
		}
449
450
		if ( in_array( self::FILTER_ANON, $options['filters'] ) ) {
451
			$conds[] = 'rc_user = 0';
452
		} elseif ( in_array( self::FILTER_NOT_ANON, $options['filters'] ) ) {
453
			$conds[] = 'rc_user != 0';
454
		}
455
456
		if ( $user->useRCPatrol() || $user->useNPPatrol() ) {
457
			// TODO: not sure if this should simply ignore patrolled filters if user does not have the patrol
@@ 459-463 (lines=5) @@
456
		if ( $user->useRCPatrol() || $user->useNPPatrol() ) {
457
			// TODO: not sure if this should simply ignore patrolled filters if user does not have the patrol
458
			// right, or maybe rather fail loud at this point, same as e.g. ApiQueryWatchlist does?
459
			if ( in_array( self::FILTER_PATROLLED, $options['filters'] ) ) {
460
				$conds[] = 'rc_patrolled != 0';
461
			} elseif ( in_array( self::FILTER_NOT_PATROLLED, $options['filters'] ) ) {
462
				$conds[] = 'rc_patrolled = 0';
463
			}
464
		}
465
466
		if ( in_array( self::FILTER_UNREAD, $options['filters'] ) ) {
@@ 466-471 (lines=6) @@
463
			}
464
		}
465
466
		if ( in_array( self::FILTER_UNREAD, $options['filters'] ) ) {
467
			$conds[] = 'rc_timestamp >= wl_notificationtimestamp';
468
		} elseif ( in_array( self::FILTER_NOT_UNREAD, $options['filters'] ) ) {
469
			// TODO: should this be changed to use Database::makeList?
470
			$conds[] = 'wl_notificationtimestamp IS NULL OR rc_timestamp < wl_notificationtimestamp';
471
		}
472
473
		return $conds;
474
	}