PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Caching » Cache » Bug #1721

fetchRow method in Cache_DB_Result: cursor is off by one

Details

Submitted2004-06-25 20:02 UTC
Fromdmintz at davidmintz dot org
StatusWont fix
PackageCache
PHP Version4.3.4
OSWindows 2000
Roadmaps(Not assigned)

Comments

[2004-06-25 20:02 UTC] dmintz at davidmintz dot org

Description:
------------
/**
* Cache_DB_Result
*
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @module Cache_DB
* @modulegroup Cache_DB
* @package Cache
* @version $Revision: 1.7 $
* @access public
*/
cursor in fetchrow() method is one too high when called inside a while loop. the first record is skipped, and the cursor overruns the end of $this->rows

Reproduce code:
---------------
see http://davidmintz.org/code/DB_Cache_bug.phps, where I point out the broken part and suggest a fix

Expected result:
----------------
You should get this:

1: Mintz, David
2: Shmoe, Joe
3: Bludgeon, Vernon T.
4: DeLillo, Don

Actual result:
--------------
but you do get this:

2: Shmoe, Joe
3: Bludgeon, Vernon T.
4: DeLillo, Don

Notice: Undefined offset: 4 in c:\php\pear\Cache\DB.php on line 331

[2004-06-25 20:05 UTC] dmintz at davidmintz dot org

it seems the trailing comma got appended to the url in my post. try this:

http://davidmintz.org/code/DB_Cache_bug.phps