Code Duplication    Length = 22-22 lines in 2 locations

includes/db/DatabaseMysqlBase.php 2 locations

@@ 247-268 (lines=22) @@
244
	 * @return stdClass|bool
245
	 * @throws DBUnexpectedError
246
	 */
247
	function fetchObject( $res ) {
248
		if ( $res instanceof ResultWrapper ) {
249
			$res = $res->result;
250
		}
251
		MediaWiki\suppressWarnings();
252
		$row = $this->mysqlFetchObject( $res );
253
		MediaWiki\restoreWarnings();
254
255
		$errno = $this->lastErrno();
256
		// Unfortunately, mysql_fetch_object does not reset the last errno.
257
		// Only check for CR_SERVER_LOST and CR_UNKNOWN_ERROR, as
258
		// these are the only errors mysql_fetch_object can cause.
259
		// See http://dev.mysql.com/doc/refman/5.0/en/mysql-fetch-row.html.
260
		if ( $errno == 2000 || $errno == 2013 ) {
261
			throw new DBUnexpectedError(
262
				$this,
263
				'Error in fetchObject(): ' . htmlspecialchars( $this->lastError() )
264
			);
265
		}
266
267
		return $row;
268
	}
269
270
	/**
271
	 * Fetch a result row as an object
@@ 283-304 (lines=22) @@
280
	 * @return array|bool
281
	 * @throws DBUnexpectedError
282
	 */
283
	function fetchRow( $res ) {
284
		if ( $res instanceof ResultWrapper ) {
285
			$res = $res->result;
286
		}
287
		MediaWiki\suppressWarnings();
288
		$row = $this->mysqlFetchArray( $res );
289
		MediaWiki\restoreWarnings();
290
291
		$errno = $this->lastErrno();
292
		// Unfortunately, mysql_fetch_array does not reset the last errno.
293
		// Only check for CR_SERVER_LOST and CR_UNKNOWN_ERROR, as
294
		// these are the only errors mysql_fetch_array can cause.
295
		// See http://dev.mysql.com/doc/refman/5.0/en/mysql-fetch-row.html.
296
		if ( $errno == 2000 || $errno == 2013 ) {
297
			throw new DBUnexpectedError(
298
				$this,
299
				'Error in fetchRow(): ' . htmlspecialchars( $this->lastError() )
300
			);
301
		}
302
303
		return $row;
304
	}
305
306
	/**
307
	 * Fetch a result row as an associative and numeric array