You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just ran into this bug. When having a node with parent_id set, setting parent_id to null will not result in the node being made root. I figured the reason lies in the function Node.php/storeNewParent()
public function storeNewParent() {
$dirty = $this->getDirty();
if ( isset($dirty[$this->getParentColumnName()]) )
Instead it should be
public function storeNewParent() {
if ( $this->isDirty($this->getParentColumnName()) && !(!$this->exists && $this->isRoot()) ) {
As isset returns false when the value is null, the is_null in the following function moveToNewParent() can otherwise never be true.
Edit: Added check to avoid setting new root node as root again - this throws an error in makeRoot() otherwise.
The text was updated successfully, but these errors were encountered:
Yes. The isset() there can be error prone because it returns false even when the value is NULL. I'll prepare a patch to change that check to use the isDirty() function.
Thanks for spotting this & providing a possible approach for a solution.
p.s. I don't quite follow the second existance/root checks. In which case makeRoot()fails?
Thanks for that. The second check in brackets ensures that new elements [ !$this->exists() ] without parent_id [ $this->isRoot() ] dont get set as root again. This is being done already by Node.php/setDefaultLeftAndRight() via creating-event.
Otherwise the same happens like in ticket #56
Hi there,
I just ran into this bug. When having a node with parent_id set, setting parent_id to null will not result in the node being made root. I figured the reason lies in the function Node.php/storeNewParent()
Instead it should be
As isset returns false when the value is null, the is_null in the following function moveToNewParent() can otherwise never be true.
Edit: Added check to avoid setting new root node as root again - this throws an error in makeRoot() otherwise.
The text was updated successfully, but these errors were encountered: