Skip to content

RBAC addRole: The role missing children, if the roles are added in wrong order #23

Description

@kenchou

Bug Report

Q A
Version(s) 3.1.0

Summary

The role permissions are wrong, if the roles are added in a different order

I use the package mezzio/mezzio-authorization-rbac.
some basic role in global.php, and add some debug role in local.php.
After merging, The local configuration is always after the global configuration

P:

  1. Role A is role B's parent, B is A's child
  2. add role with role name (string)

if add A before B, role A has child B, It's OK.
But if add A after B, role A hash no children!

Current behavior

How to reproduce

return [
    // ...
    'mezzio-authorization-rbac' => [
        'roles' => [
            '__member__' => ['SystemAdministrator'],
            '__guest__' => ['__member__'],
            'SystemAdministrator' => [],
        ],
        'permissions' => [
            '__guest__' => [
                'home',
                'account.login',
                'account.logout',
            ],
            '__member__' => [
                'account.profile',
            ],
        ],
    ]
];

if the role 'SystemAdministrator' is after member, it has no children.
if the role 'SystemAdministrator' is before member, the result is OK.

Expected behavior

SystemAdministrator has child member, ignore the order of addition.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions