yiiext / nested-set-behavior

AR models behavior that allows to work with nested sets tree.
http://www.yiiframework.com/extension/nestedsetbehavior/
BSD 3-Clause "New" or "Revised" License
157 stars 64 forks source link

isLeaf behavior, when all children were deleted - bug or feature??? #8

Closed bethrezen closed 12 years ago

bethrezen commented 12 years ago

Assume we have tree: 1 ---2 ------3 ------4 ------5

After calling deleteNode() on (3,4,5) the node 2 has lft 2 and rgt 5. Checking $node2->isLeaf() will return false, because 5-2!==1

I've used isLeaf to render correctly jsTree with folders and files. When $node->isLeaf()==true - it's a file. So I have to use $node->children()->count()==0 instead of $node->isLeaf()

Is it a bug of isLeaf() or deleteNode(), OR is it a feature?

cebe commented 12 years ago

for sure not a feature, should be fixed, thanks.

bethrezen commented 12 years ago

I think the way of correcting ID's will be not correct, while it breaks continuous auto_increment for id. So the best way to fix is to check children count and maybe cache it to static variable.

creocoder commented 12 years ago

Invalid, there is no this bug. Try to use latest release. $node2->isLeaf() returns true and it's lft=2 and rgt=3.