From 36c18cffc5c507bab9ff338f74f91c33e4a126f5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20Laxstr=C3=B6m?= Date: Sun, 10 Mar 2013 09:46:00 +0000 Subject: [PATCH] numRows on MySQL no longer propagates unrelated errors Bug: 42430 Change-Id: Ie2277c97177be34f4a48dfa0eac736a2b5716f22 --- RELEASE-NOTES-1.21 | 1 + includes/db/DatabaseMysql.php | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/RELEASE-NOTES-1.21 b/RELEASE-NOTES-1.21 index 883fb8ba58..58fc5c7d11 100644 --- a/RELEASE-NOTES-1.21 +++ b/RELEASE-NOTES-1.21 @@ -194,6 +194,7 @@ production. * (bug 42184) $wgUploadSizeWarning missing second variable * (bug 40326) Check if files exist with a different extension during uploading * (bug 34798) Updated CSS for Atom/RSS recent changes feeds to match on-wiki diffs. +* (bug 42430) Calling numRows on MySQL no longer propagates unrelated errors. === API changes in 1.21 === * prop=revisions can now report the contentmodel and contentformat. diff --git a/includes/db/DatabaseMysql.php b/includes/db/DatabaseMysql.php index fab0e96ee5..011c0cbaf6 100644 --- a/includes/db/DatabaseMysql.php +++ b/includes/db/DatabaseMysql.php @@ -208,7 +208,7 @@ class DatabaseMysql extends DatabaseBase { // Unfortunately, mysql_fetch_object does not reset the last errno. // Only check for CR_SERVER_LOST and CR_UNKNOWN_ERROR, as // these are the only errors mysql_fetch_object can cause. - // See http://dev.mysql.com/doc/refman/5.0/es/mysql-fetch-row.html. + // See http://dev.mysql.com/doc/refman/5.0/en/mysql-fetch-row.html. if( $errno == 2000 || $errno == 2013 ) { throw new DBUnexpectedError( $this, 'Error in fetchObject(): ' . htmlspecialchars( $this->lastError() ) ); } @@ -232,7 +232,7 @@ class DatabaseMysql extends DatabaseBase { // Unfortunately, mysql_fetch_array does not reset the last errno. // Only check for CR_SERVER_LOST and CR_UNKNOWN_ERROR, as // these are the only errors mysql_fetch_object can cause. - // See http://dev.mysql.com/doc/refman/5.0/es/mysql-fetch-row.html. + // See http://dev.mysql.com/doc/refman/5.0/en/mysql-fetch-row.html. if( $errno == 2000 || $errno == 2013 ) { throw new DBUnexpectedError( $this, 'Error in fetchRow(): ' . htmlspecialchars( $this->lastError() ) ); } @@ -251,9 +251,11 @@ class DatabaseMysql extends DatabaseBase { wfSuppressWarnings(); $n = mysql_num_rows( $res ); wfRestoreWarnings(); - if( $this->lastErrno() ) { - throw new DBUnexpectedError( $this, 'Error in numRows(): ' . htmlspecialchars( $this->lastError() ) ); - } + // Unfortunately, mysql_num_rows does not reset the last errno. + // We are not checking for any errors here, since + // these are no errors mysql_num_rows can cause. + // See http://dev.mysql.com/doc/refman/5.0/en/mysql-fetch-row.html. + // See https://bugzilla.wikimedia.org/42430 return $n; } -- 2.20.1