schmittjoh/JMSSecurityExtraBundle — Issue #30: expressions don't consider role hierarchy
Author: craue
Created: 2011-12-05 18:04:04+00:00
State: open

With

```
security:
role_hierarchy:
ROLE_SUPER_ADMIN: ROLE_ADMIN
```

defined, the expression `hasRole("ROLE_ADMIN")` fails although the user has role `ROLE_SUPER_ADMIN`.

In the generated expression code

```
getRoles();
if (isset($context['role_hierarchy'])) {
$a = $context['role_hierarchy']->getReachableRoles($a);
}

$b = array();
foreach ($a as $role) {
$b[$role->getRole()] = true;
}
$a = $b;

return isset($a['ROLE_ADMIN']);
};
```

`isset($context['role_hierarchy'])` evaluates to false which makes the defined role hierarchy being ignored.