Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.3.7

Bug #13080 MDB2simple _setup(): parentId cleared if parentId column is mapped to "parentid"
Submitted: 2008-02-06 22:39 UTC
From: redmoskito Assigned: dufuz
Status: Closed Package: Tree (version 0.3.2)
PHP Version: 5.2.4 OS: Ubuntu 7.04
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 27 + 50 = ?

 
 [2008-02-06 22:39 UTC] redmoskito (Kyle Simek)
Description: ------------ Using MDB2 simple tree, if you map the parentId column to 'parentid', all parentId's will be blank after calling setup(); I believe this problem arises because of the following code, which expects "parentid" to exists as a result of the tree object creating it, not because it is actually a column in the table: // BEGIN SNIPPET (MDB2simple.php, lines 142-146) // Account for the fact the by default MDB2 lower cases field names foreach ($res as $index => $value) { $res[$index]['parentId'] = $res[$index]['parentid']; unset( $res[$index]['parentid'] ); } // END SNIPPET Then, column mappings are handled. The code tries to map parentid to parentId, and then unsets parentid. However, the snippet above already unset parentid, so parentId get set to NULL. This seems like an obscure bug, but it could come up quite often, as "parentid" is a not unreasonable field name for the parent id. Test script: --------------- $tree = TREE::setup('Memory_MDB2simple', 'mysql://user:pass@localhost/mydb', array('table' => 'app_paths', 'order' => 'name', 'whereAddOn' => 'enabled=1', 'columnNameMaps' => array( 'id' => 'table_id', 'parentId' => 'parentid' ))); print_r($tree->data) exit; Expected result: ---------------- every node in the dumped data should have a valid parentId. Actual result: -------------- Every node has a blank parentId.

Comments

 [2008-03-23 16:22 UTC] dufuz (Helgi Þormar Þorbjörnsson)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. I didn't have much time to test the patch but if you can give it a whirl then that would be great: http://cvs.php.net/viewvc.cgi/pear/Tree/Memory/MDB2simple.php?r1=1.1.2.2&r2=1.1.2.3&pathrev=Tree_0_3_0&view=patch Reopen this report if it does not work for you.