yii2
yii2 copied to clipboard
`detectLoop()` not include detection at the child level.
in yii\rbac\DbManager.php
The loop starts checking from the grandchild level, but the child level is not being checked. Therefore, when I use canAddChild(), it cannot effectively validate the case where a parent is being added to its own child.
Any idea for the fix?
I think it should be:
protected function detectLoop($parent, $child)
{
foreach ($this->getChildren($parent->name) as $directChild) {
if ($directChild->name === $child->name) {
return true;
}
if ($this->detectLoop($directChild, $child)) {
return true;
}
}
return false;
}
Do you have time to do a pull request?