Database: Cast to int in estimateRowCount(), selectRowCount()

Doc comments state that these methods return ints. In order to ensure
that, values must be cast to int before they are returned.

With respect to selectRowCount(), follows-up 65f81d2843.

Change-Id: I108221ce4ad1b5b103b015fe875de54e04781741
This commit is contained in:
Kevin Israel 2015-01-22 10:36:18 -05:00
parent 1274a261c3
commit 5f3957498b
5 changed files with 6 additions and 6 deletions

View file

@ -181,7 +181,7 @@ class ApiQueryUserInfo extends ApiQueryBase {
if ( $count >= self::WL_UNREAD_LIMIT ) {
$vals['unreadcount'] = self::WL_UNREAD_LIMIT . '+';
} else {
$vals['unreadcount'] = (int)$count;
$vals['unreadcount'] = $count;
}
}

View file

@ -1814,7 +1814,7 @@ abstract class DatabaseBase implements IDatabase {
if ( $res ) {
$row = $this->fetchRow( $res );
$rows = ( isset( $row['rowcount'] ) ) ? $row['rowcount'] : 0;
$rows = ( isset( $row['rowcount'] ) ) ? (int)$row['rowcount'] : 0;
}
return $rows;
@ -1844,7 +1844,7 @@ abstract class DatabaseBase implements IDatabase {
if ( $res ) {
$row = $this->fetchRow( $res );
$rows = ( isset( $row['rowcount'] ) ) ? $row['rowcount'] : 0;
$rows = ( isset( $row['rowcount'] ) ) ? (int)$row['rowcount'] : 0;
}
return $rows;

View file

@ -518,7 +518,7 @@ class DatabaseMssql extends DatabaseBase {
$row = $this->fetchRow( $res );
if ( isset( $row['EstimateRows'] ) ) {
$rows = $row['EstimateRows'];
$rows = (int)$row['EstimateRows'];
}
}

View file

@ -468,7 +468,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
$rows *= $plan->rows > 0 ? $plan->rows : 1; // avoid resetting to zero
}
return $rows;
return (int)$rows;
}
/**

View file

@ -712,7 +712,7 @@ class DatabasePostgres extends DatabaseBase {
$row = $this->fetchRow( $res );
$count = array();
if ( preg_match( '/rows=(\d+)/', $row[0], $count ) ) {
$rows = $count[1];
$rows = (int)$count[1];
}
}