numRows on MySQL no longer propagates unrelated errors
authorNiklas Laxström <niklas.laxstrom@gmail.com>
Sun, 10 Mar 2013 09:46:00 +0000 (09:46 +0000)
committerNiklas Laxström <niklas.laxstrom@gmail.com>
Sun, 10 Mar 2013 09:46:00 +0000 (09:46 +0000)
Bug: 42430
Change-Id: Ie2277c97177be34f4a48dfa0eac736a2b5716f22

RELEASE-NOTES-1.21
includes/db/DatabaseMysql.php

index 883fb8b..58fc5c7 100644 (file)
@@ -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.
index fab0e96..011c0cb 100644 (file)
@@ -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;
        }