diff --git a/libraries/legacy/categories/categories.php b/libraries/legacy/categories/categories.php index 9f94840291b65..fdb8f9a3b8aa3 100644 --- a/libraries/legacy/categories/categories.php +++ b/libraries/legacy/categories/categories.php @@ -344,7 +344,9 @@ protected function _load($id) $this->_nodes[$result->id]->setParent($this->_nodes[$result->parent_id]); } - if (!isset($this->_nodes[$result->parent_id])) + // If the node's parent id is not in the _nodes list and the node is not root (doesn't have parent_id == 0), + // then remove the node from the list + if (!(isset($this->_nodes[$result->parent_id]) || $result->parent_id == 0)) { unset($this->_nodes[$result->id]); continue;