Home » Internationalization » Translation2 » Bug #8734
Wrong use of list()
Details
| Submitted | 2006-09-19 10:07 UTC |
|---|---|
| From | chrismontijn at yahoo dot com |
| Assigned | quipo |
| Status | Closed |
| Package | Translation2 |
| PHP Version | 4.4.2 |
| OS | Windows XP |
| Roadmaps | (Not assigned) |
Comments
[2006-09-19 10:07 UTC] chrismontijn at yahoo dot com
Description:
------------
When using an existing db connection, with fetchmode set to associative, to instantiate an translation2 object at least one (didn't check further) list() function is not working properly. For example in the MDB2.php container on line 217 in function getPage() there is a list() not working properly, because the indices of the result array are tablecolumnnames instead of numbers (starting from zero).
Test script:
---------------
$dsn = 'somedsn';
$db =& MDB2::connect($dsn);
// !This is where it goes wrong
$db->setFetchmode(MDB2_FETCHMODE_ASSOC);
// instantiate translation2 with this database connection
$tr =& Translation2::factory($dbdriver, &$db, $TR_options);
$tr->setLang('somelang');
$tr =& $tr->getDecorator('CacheMemory');
$tr->setPageID('someGroup');
$tr->get('somestr');
Expected result:
----------------
I expect to see no notices about undefined offsets.
Actual result:
--------------
When display notices are on in php.ini page shows following errors:
Notice: Undefined offset: 1 in c:\Inetpub\wwwroot\pear\Translation2\Container\mdb2.php on line 217
Notice: Undefined offset: 0 in c:\Inetpub\wwwroot\pear\Translation2\Container\mdb2.php on line 217
[2006-09-19 10:26 UTC] chrismontijn at yahoo dot com
A simple solution is to change line 217 in container/mdb2.php
while (list($key, $value) = $res->fetchRow()) {
to
while (list($key, $value) = $res->fetchRow(MDB2_FETCHMODE_ORDERED)) {