Fix guarding of MySQL's numRows()

It can be true for successful write queries, not just false.

f3a197e49b introduced a caller which calls numRows() on the return
value of CREATE TEMPORARY TABLE queries, and it improved guarding of
numRows() in the PostgreSQL and SQLite cases accordingly, but it
neglected MySQL.

Bug: T201900
Change-Id: I8ae754a2518d9e47b093c31c20d98daaba913513
This commit is contained in:
Tim Starling 2018-10-08 14:46:37 +11:00
parent 936b958cb9
commit 9fbbce857c
2 changed files with 3 additions and 2 deletions

View file

@ -359,7 +359,7 @@ abstract class DatabaseMysqlBase extends Database {
$res = $res->result;
}
Wikimedia\suppressWarnings();
$n = $res ? $this->mysqlNumRows( $res ) : 0;
$n = !is_bool( $res ) ? $this->mysqlNumRows( $res ) : 0;
Wikimedia\restoreWarnings();
// Unfortunately, mysql_num_rows does not reset the last errno.

View file

@ -394,7 +394,8 @@ interface IDatabase {
public function fetchRow( $res );
/**
* Get the number of rows in a result object
* Get the number of rows in a query result. If the query did not return
* any rows (for example, if it was a write query), this returns zero.
*
* @param mixed $res A SQL result
* @return int