Code Duplication    Length = 22-22 lines in 2 locations

includes/libs/rdbms/database/DatabaseMysqlBase.php 2 locations

@@ 265-286 (lines=22) @@
262
	 * @return stdClass|bool
263
	 * @throws DBUnexpectedError
264
	 */
265
	function fetchObject( $res ) {
266
		if ( $res instanceof ResultWrapper ) {
267
			$res = $res->result;
268
		}
269
		MediaWiki\suppressWarnings();
270
		$row = $this->mysqlFetchObject( $res );
271
		MediaWiki\restoreWarnings();
272
273
		$errno = $this->lastErrno();
274
		// Unfortunately, mysql_fetch_object does not reset the last errno.
275
		// Only check for CR_SERVER_LOST and CR_UNKNOWN_ERROR, as
276
		// these are the only errors mysql_fetch_object can cause.
277
		// See http://dev.mysql.com/doc/refman/5.0/en/mysql-fetch-row.html.
278
		if ( $errno == 2000 || $errno == 2013 ) {
279
			throw new DBUnexpectedError(
280
				$this,
281
				'Error in fetchObject(): ' . htmlspecialchars( $this->lastError() )
282
			);
283
		}
284
285
		return $row;
286
	}
287
288
	/**
289
	 * Fetch a result row as an object
@@ 301-322 (lines=22) @@
298
	 * @return array|bool
299
	 * @throws DBUnexpectedError
300
	 */
301
	function fetchRow( $res ) {
302
		if ( $res instanceof ResultWrapper ) {
303
			$res = $res->result;
304
		}
305
		MediaWiki\suppressWarnings();
306
		$row = $this->mysqlFetchArray( $res );
307
		MediaWiki\restoreWarnings();
308
309
		$errno = $this->lastErrno();
310
		// Unfortunately, mysql_fetch_array does not reset the last errno.
311
		// Only check for CR_SERVER_LOST and CR_UNKNOWN_ERROR, as
312
		// these are the only errors mysql_fetch_array can cause.
313
		// See http://dev.mysql.com/doc/refman/5.0/en/mysql-fetch-row.html.
314
		if ( $errno == 2000 || $errno == 2013 ) {
315
			throw new DBUnexpectedError(
316
				$this,
317
				'Error in fetchRow(): ' . htmlspecialchars( $this->lastError() )
318
			);
319
		}
320
321
		return $row;
322
	}
323
324
	/**
325
	 * Fetch a result row as an associative and numeric array