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

Bug #3536 getSiblings doesn't work on root level
Submitted: 2005-02-20 21:16 UTC
From: finex Assigned: datenpunk
Status: Closed Package: DB_NestedSet
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  


 [2005-02-20 21:16 UTC] finex
Description: ------------ getSiblings() returns an error when looking for siblings of root nodes. I fixed for me by replacing the 'return' line with the following code: if (empty($parent)) { return $this->getRootNodes($keepAsArray, $aliasFields, $addSQL); } else { return $this->getChildren($parent, $keepAsArray, $aliasFields, $addSQL); } Reproduce code: --------------- Just use getSiblings() on a root node. Expected result: ---------------- Return of a list of siblings even on root level. Actual result: -------------- PEAR:Error

Comments

 [2005-03-12 23:44 UTC] nomail at nomail dot com
As there is only one root element in a tree ther can't be a sibling. So this seems to be the correct behaviour
 [2005-03-12 23:54 UTC] finex
Well, your method is called getRootNodes (<- s means probably that there can be more than one).
 [2005-03-13 00:25 UTC] d dot khan at ventigo dot com
The previous comment stating this as expected behavior wasn't by a maintainer. So it's not 'his' method :) O.K. enough confusion. A Nested Set in DB_NestedSet _can_ have multiple rootnodes and _no_ the error you get isn't the expected behavior. So this will be fixed wth the next version (and soon in CVS). Thanks for reporting this. Daniel Khan
 [2005-05-12 09:21 UTC] no at no dot thx
even if i don't belong to the maintainers... a root node can't have a sibling. A sibling has to be related with the node. As a root element can't have any relatives beside the children it can't have siblings. If the getSiblings() would deliver siblings on the root level that definitly would be wrong.
 [2005-05-12 09:29 UTC] d dot khan at ventigo dot com
Hello Anoymous, That's not true. DB_NestedSet uses a rootnode for each node inside the top level. So 5 top level nodes mean 5 rootnodes. It's |-root1 |-root2 |-root3 And not: root0-- |-node1 |-node2 |-node3 Long term short. A rootnode can have siblings in DB_NestedSet if you believe me or not. -- Daniel Khan
 [2005-10-25 22:09 UTC] datenpunk at php dot net
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.