Przeglądaj źródła

[ZF-9213] Zend_Db_Table:

- fixed indexes negatives.

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@22579 44c647ce-9c0f-0410-b52a-842ac1e357ba
ramon 15 lat temu
rodzic
commit
619b864970

+ 1 - 1
library/Zend/Db/Table/Rowset/Abstract.php

@@ -294,7 +294,7 @@ abstract class Zend_Db_Table_Rowset_Abstract implements SeekableIterator, Counta
      */
     public function valid()
     {
-        return $this->_pointer < $this->_count;
+        return $this->_pointer >= 0 && $this->_pointer < $this->_count;
     }
 
     /**

+ 10 - 0
tests/Zend/Db/Table/Rowset/TestCommon.php

@@ -264,4 +264,14 @@ abstract class Zend_Db_Table_Rowset_TestCommon extends Zend_Db_Table_TestSetup
         $this->assertFalse($connected);
     }
 
+    /**
+     * @group ZF-9213
+     */
+    public function testTableRowsetIndexesValid()
+    {
+        $rowset = $this->_table['bugs']->fetchAll();
+        $this->assertNull($rowset[-1]);
+        $this->assertTrue($rowset[0] instanceof Zend_Db_Table_Row);
+        $this->assertNull($rowset[count($rowset) + 2]);
+    }
 }