yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.24k stars 6.91k forks source link

$childRoles = Yii::$app->authManager->getChildRoles($id); work wrong #12976

Closed muratcelik27 closed 8 years ago

muratcelik27 commented 8 years ago

$id is my any role and want to get childRoles. But getChildRoles($id) return and my $id role.

bbf910bd325a4613af346ae65d576e68

Yii version : 2.0.10 PHP version : 5.6.12
Operating system : mac os x sierra

samdark commented 8 years ago

Please provide code you've created RBAC hierarchy with and code that you're calling to get the issue.

yii-bot commented 8 years ago

Thanks for posting in our issue tracker. In order to properly assist you, we need additional information:

Thanks!

This is an automated comment, triggered by adding the label status:need more info.

evgen-d commented 8 years ago

@murat-celik getChildRoles() return yii\rbac\Role[]

All roles directly adding to the role. The array is indexed by the role names. First element is a Role item that are getting by $roleName.

So this is not a bug

samdark commented 8 years ago

@evgen-d is right.

muratcelik27 commented 8 years ago

1) I have one role. 2) Role name is "Sevko". 3) "Sevko" no have any Child Role. 4) Run getChildRoles("Sevko").
5) Return yii\rbac\Role[]. 6) In this return exist also "Sevko" Role. 7) This is really true usage ?

@evgen-d @samdark

samdark commented 8 years ago

Well, at least it is what's implemented and what is described in phpdoc.

samdark commented 8 years ago

https://github.com/yiisoft/yii2/commit/324b38d504b96b9bfc739094accda1f36a43548c