Kaynağa Gözat

ZF-7223: Zend_Db_Select::limit(), an empty first parameter won't be converted to max integer in 32-bits architecture
intval($value) returns 0 if $value > PHP_INT_MAX

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@19154 44c647ce-9c0f-0410-b52a-842ac1e357ba

mikaelkael 16 yıl önce
ebeveyn
işleme
7880a483da

+ 1 - 2
library/Zend/Db/Select.php

@@ -1258,8 +1258,7 @@ class Zend_Db_Select
 
         if (!empty($this->_parts[self::LIMIT_OFFSET])) {
             $offset = (int) $this->_parts[self::LIMIT_OFFSET];
-            // This should reduce to the max integer PHP can support
-            $count = intval(9223372036854775807);
+            $count = PHP_INT_MAX;
         }
 
         if (!empty($this->_parts[self::LIMIT_COUNT])) {

+ 11 - 0
tests/Zend/Db/Select/StaticTest.php

@@ -702,6 +702,17 @@ class Zend_Db_Select_StaticTest extends Zend_Db_Select_TestCommon
         $this->assertEquals($target, $select->assemble());
     }
 
+    /**
+     * @group ZF-7223
+     */
+    public function testMaxIntegerValueWithLimit()
+    {
+        $select = $this->_db->select();
+        $select->from('table1')->limit(0, 5);
+        $target = 'SELECT "table1".* FROM "table1" LIMIT ' . PHP_INT_MAX . ' OFFSET 5';
+        $this->assertEquals($target, $select->assemble());
+    }
+
     public function getDriver()
     {
         return 'Static';