Database: Cast to int in estimateRowCount(), selectRowCount()
authorKevin Israel <pleasestand@live.com>
Thu, 22 Jan 2015 15:36:18 +0000 (10:36 -0500)
committerKevin Israel <pleasestand@live.com>
Fri, 6 Feb 2015 10:03:45 +0000 (05:03 -0500)
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

includes/api/ApiQueryUserInfo.php
includes/db/Database.php
includes/db/DatabaseMssql.php
includes/db/DatabaseMysqlBase.php
includes/db/DatabasePostgres.php

index aa38564..7fc0ba8 100644 (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;
                        }
                }
 
index 92d998c..e95f134 100644 (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;
index a7bc6dd..d62769c 100644 (file)
@@ -518,7 +518,7 @@ class DatabaseMssql extends DatabaseBase {
                        $row = $this->fetchRow( $res );
 
                        if ( isset( $row['EstimateRows'] ) ) {
-                               $rows = $row['EstimateRows'];
+                               $rows = (int)$row['EstimateRows'];
                        }
                }
 
index 7b903d6..458b286 100644 (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;
        }
 
        /**
index ce14d7a..abf26e0 100644 (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];
                        }
                }