Code Duplication    Length = 5-6 lines in 5 locations

includes/WatchedItemQueryService.php 5 locations

@@ 398-402 (lines=5) @@
395
	private function getWatchedItemsWithRCInfoQueryFilterConds( User $user, array $options ) {
396
		$conds = [];
397
398
		if ( in_array( self::FILTER_MINOR, $options['filters'] ) ) {
399
			$conds[] = 'rc_minor != 0';
400
		} elseif ( in_array( self::FILTER_NOT_MINOR, $options['filters'] ) ) {
401
			$conds[] = 'rc_minor = 0';
402
		}
403
404
		if ( in_array( self::FILTER_BOT, $options['filters'] ) ) {
405
			$conds[] = 'rc_bot != 0';
@@ 404-408 (lines=5) @@
401
			$conds[] = 'rc_minor = 0';
402
		}
403
404
		if ( in_array( self::FILTER_BOT, $options['filters'] ) ) {
405
			$conds[] = 'rc_bot != 0';
406
		} elseif ( in_array( self::FILTER_NOT_BOT, $options['filters'] ) ) {
407
			$conds[] = 'rc_bot = 0';
408
		}
409
410
		if ( in_array( self::FILTER_ANON, $options['filters'] ) ) {
411
			$conds[] = 'rc_user = 0';
@@ 410-414 (lines=5) @@
407
			$conds[] = 'rc_bot = 0';
408
		}
409
410
		if ( in_array( self::FILTER_ANON, $options['filters'] ) ) {
411
			$conds[] = 'rc_user = 0';
412
		} elseif ( in_array( self::FILTER_NOT_ANON, $options['filters'] ) ) {
413
			$conds[] = 'rc_user != 0';
414
		}
415
416
		if ( $user->useRCPatrol() || $user->useNPPatrol() ) {
417
			// TODO: not sure if this should simply ignore patrolled filters if user does not have the patrol
@@ 419-423 (lines=5) @@
416
		if ( $user->useRCPatrol() || $user->useNPPatrol() ) {
417
			// TODO: not sure if this should simply ignore patrolled filters if user does not have the patrol
418
			// right, or maybe rather fail loud at this point, same as e.g. ApiQueryWatchlist does?
419
			if ( in_array( self::FILTER_PATROLLED, $options['filters'] ) ) {
420
				$conds[] = 'rc_patrolled != 0';
421
			} elseif ( in_array( self::FILTER_NOT_PATROLLED, $options['filters'] ) ) {
422
				$conds[] = 'rc_patrolled = 0';
423
			}
424
		}
425
426
		if ( in_array( self::FILTER_UNREAD, $options['filters'] ) ) {
@@ 426-431 (lines=6) @@
423
			}
424
		}
425
426
		if ( in_array( self::FILTER_UNREAD, $options['filters'] ) ) {
427
			$conds[] = 'rc_timestamp >= wl_notificationtimestamp';
428
		} elseif ( in_array( self::FILTER_NOT_UNREAD, $options['filters'] ) ) {
429
			// TODO: should this be changed to use Database::makeList?
430
			$conds[] = 'wl_notificationtimestamp IS NULL OR rc_timestamp < wl_notificationtimestamp';
431
		}
432
433
		return $conds;
434
	}