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

Error if role name is 0 #9775

Closed Claud closed 8 years ago

Claud commented 9 years ago

I have default roles

const ROLE_SUPER_ADMIN = 0;
const ROLE_ADMIN = 1;
....

This check not work

https://github.com/yiisoft/yii2/blob/master/framework/rbac/DbManager.php#L219

samdark commented 9 years ago

That's quite weird name for a role... Usualy names are meaningful strings like "role_super_admin".

dynasource commented 8 years ago

the whole RBAC architecture is built around strings. Examples:

A lot has to be changed in the architecture in order to accept integers.

Its easier for you to implement strings for your constants. This which would not lead to many problems if these are applied consistently. An example:

const ROLE_SUPER_ADMIN = 'super-admin';
const ROLE_ADMIN = 'admin';

Please elaborate if integers are of vital importance in order for this issue to be opened again.

dynasource commented 8 years ago

more opinions about this https://github.com/yiisoft/yii2/pull/9832#issuecomment-145531425