From: Kevin Israel Date: Thu, 22 Jan 2015 15:36:18 +0000 (-0500) Subject: Database: Cast to int in estimateRowCount(), selectRowCount() X-Git-Tag: 1.31.0-rc.0~12495^2 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=5f3957498b5819375f525949e79cad8564d998ec;p=lhc%2Fweb%2Fwiklou.git 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 65f81d284386. Change-Id: I108221ce4ad1b5b103b015fe875de54e04781741 --- diff --git a/includes/api/ApiQueryUserInfo.php b/includes/api/ApiQueryUserInfo.php index aa38564e1c..7fc0ba88b7 100644 --- a/includes/api/ApiQueryUserInfo.php +++ b/includes/api/ApiQueryUserInfo.php @@ -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; } } diff --git a/includes/db/Database.php b/includes/db/Database.php index 92d998c60b..e95f134c01 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -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; diff --git a/includes/db/DatabaseMssql.php b/includes/db/DatabaseMssql.php index a7bc6dd621..d62769cc60 100644 --- a/includes/db/DatabaseMssql.php +++ b/includes/db/DatabaseMssql.php @@ -518,7 +518,7 @@ class DatabaseMssql extends DatabaseBase { $row = $this->fetchRow( $res ); if ( isset( $row['EstimateRows'] ) ) { - $rows = $row['EstimateRows']; + $rows = (int)$row['EstimateRows']; } } diff --git a/includes/db/DatabaseMysqlBase.php b/includes/db/DatabaseMysqlBase.php index 7b903d6826..458b286948 100644 --- a/includes/db/DatabaseMysqlBase.php +++ b/includes/db/DatabaseMysqlBase.php @@ -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; } /** diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php index ce14d7a969..abf26e06ff 100644 --- a/includes/db/DatabasePostgres.php +++ b/includes/db/DatabasePostgres.php @@ -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]; } }