Code Duplication    Length = 5-5 lines in 5 locations

includes/api/ApiQueryAllCategories.php 1 location

@@ 86-90 (lines=5) @@
83
			$this->addWhereRange( 'cat_pages', 'older', $max, $min );
84
		}
85
86
		if ( isset( $params['prefix'] ) ) {
87
			$this->addWhere( 'cat_title' . $db->buildLike(
88
				$this->titlePartToKey( $params['prefix'], NS_CATEGORY ),
89
				$db->anyString() ) );
90
		}
91
92
		$this->addOption( 'LIMIT', $params['limit'] + 1 );
93
		$sort = ( $params['dir'] == 'descending' ? ' DESC' : '' );

includes/api/ApiQueryAllImages.php 1 location

@@ 139-143 (lines=5) @@
136
			$to = ( $params['to'] === null ? null : $this->titlePartToKey( $params['to'], NS_FILE ) );
137
			$this->addWhereRange( 'img_name', ( $ascendingOrder ? 'newer' : 'older' ), $from, $to );
138
139
			if ( isset( $params['prefix'] ) ) {
140
				$this->addWhere( 'img_name' . $db->buildLike(
141
					$this->titlePartToKey( $params['prefix'], NS_FILE ),
142
					$db->anyString() ) );
143
			}
144
		} else {
145
			// Check mutually exclusive params
146
			$disallowed = [ 'from', 'to', 'prefix' ];

includes/api/ApiQueryAllPages.php 1 location

@@ 98-102 (lines=5) @@
95
			: $this->titlePartToKey( $params['to'], $params['namespace'] ) );
96
		$this->addWhereRange( 'page_title', $dir, $from, $to );
97
98
		if ( isset( $params['prefix'] ) ) {
99
			$this->addWhere( 'page_title' . $db->buildLike(
100
				$this->titlePartToKey( $params['prefix'], $params['namespace'] ),
101
				$db->anyString() ) );
102
		}
103
104
		if ( is_null( $resultPageSet ) ) {
105
			$selectFields = [

includes/api/ApiQueryDeletedrevs.php 1 location

@@ 208-212 (lines=5) @@
205
				: $this->titlePartToKey( $params['to'], $params['namespace'] );
206
			$this->addWhereRange( 'ar_title', $dir, $from, $to );
207
208
			if ( isset( $params['prefix'] ) ) {
209
				$this->addWhere( 'ar_title' . $db->buildLike(
210
					$this->titlePartToKey( $params['prefix'], $params['namespace'] ),
211
					$db->anyString() ) );
212
			}
213
		}
214
215
		if ( !is_null( $params['user'] ) ) {

includes/api/ApiQueryFilearchive.php 1 location

@@ 102-106 (lines=5) @@
99
		$from = ( $params['from'] === null ? null : $this->titlePartToKey( $params['from'], NS_FILE ) );
100
		$to = ( $params['to'] === null ? null : $this->titlePartToKey( $params['to'], NS_FILE ) );
101
		$this->addWhereRange( 'fa_name', $dir, $from, $to );
102
		if ( isset( $params['prefix'] ) ) {
103
			$this->addWhere( 'fa_name' . $db->buildLike(
104
				$this->titlePartToKey( $params['prefix'], NS_FILE ),
105
				$db->anyString() ) );
106
		}
107
108
		$sha1Set = isset( $params['sha1'] );
109
		$sha1base36Set = isset( $params['sha1base36'] );