Code Duplication    Length = 20-21 lines in 3 locations

includes/api/ApiQueryDeletedRevisions.php 1 location

@@ 96-115 (lines=20) @@
93
			$this->addWhereFld( 'ct_tag', $params['tag'] );
94
		}
95
96
		if ( $this->fetchContent ) {
97
			// Modern MediaWiki has the content for deleted revs in the 'text'
98
			// table using fields old_text and old_flags. But revisions deleted
99
			// pre-1.5 store the content in the 'archive' table directly using
100
			// fields ar_text and ar_flags, and no corresponding 'text' row. So
101
			// we have to LEFT JOIN and fetch all four fields.
102
			$this->addTables( 'text' );
103
			$this->addJoinConds(
104
				[ 'text' => [ 'LEFT JOIN', [ 'ar_text_id=old_id' ] ] ]
105
			);
106
			$this->addFields( [ 'ar_text', 'ar_flags', 'old_text', 'old_flags' ] );
107
108
			// This also means stricter restrictions
109
			if ( !$user->isAllowedAny( 'undelete', 'deletedtext' ) ) {
110
				$this->dieUsage(
111
					'You don\'t have permission to view deleted revision content',
112
					'permissiondenied'
113
				);
114
			}
115
		}
116
117
		$dir = $params['dir'];
118

includes/api/ApiQueryDeletedrevs.php 1 location

@@ 151-171 (lines=21) @@
148
			$this->addWhereFld( 'ct_tag', $params['tag'] );
149
		}
150
151
		if ( $fld_content ) {
152
			// Modern MediaWiki has the content for deleted revs in the 'text'
153
			// table using fields old_text and old_flags. But revisions deleted
154
			// pre-1.5 store the content in the 'archive' table directly using
155
			// fields ar_text and ar_flags, and no corresponding 'text' row. So
156
			// we have to LEFT JOIN and fetch all four fields, plus ar_text_id
157
			// to be able to tell the difference.
158
			$this->addTables( 'text' );
159
			$this->addJoinConds(
160
				[ 'text' => [ 'LEFT JOIN', [ 'ar_text_id=old_id' ] ] ]
161
			);
162
			$this->addFields( [ 'ar_text', 'ar_flags', 'ar_text_id', 'old_text', 'old_flags' ] );
163
164
			// This also means stricter restrictions
165
			if ( !$user->isAllowedAny( 'undelete', 'deletedtext' ) ) {
166
				$this->dieUsage(
167
					'You don\'t have permission to view deleted revision content',
168
					'permissiondenied'
169
				);
170
			}
171
		}
172
		// Check limits
173
		$userMax = $fld_content ? ApiBase::LIMIT_SML1 : ApiBase::LIMIT_BIG1;
174
		$botMax = $fld_content ? ApiBase::LIMIT_SML2 : ApiBase::LIMIT_BIG2;

includes/api/ApiQueryAllDeletedRevisions.php 1 location

@@ 138-157 (lines=20) @@
135
			$this->addWhereFld( 'ct_tag', $params['tag'] );
136
		}
137
138
		if ( $this->fetchContent ) {
139
			// Modern MediaWiki has the content for deleted revs in the 'text'
140
			// table using fields old_text and old_flags. But revisions deleted
141
			// pre-1.5 store the content in the 'archive' table directly using
142
			// fields ar_text and ar_flags, and no corresponding 'text' row. So
143
			// we have to LEFT JOIN and fetch all four fields.
144
			$this->addTables( 'text' );
145
			$this->addJoinConds(
146
				[ 'text' => [ 'LEFT JOIN', [ 'ar_text_id=old_id' ] ] ]
147
			);
148
			$this->addFields( [ 'ar_text', 'ar_flags', 'old_text', 'old_flags' ] );
149
150
			// This also means stricter restrictions
151
			if ( !$user->isAllowedAny( 'undelete', 'deletedtext' ) ) {
152
				$this->dieUsage(
153
					'You don\'t have permission to view deleted revision content',
154
					'permissiondenied'
155
				);
156
			}
157
		}
158
159
		$miser_ns = null;
160