Code Duplication    Length = 22-22 lines in 2 locations

includes/db/DatabaseMysqlBase.php 2 locations

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