I’ve written a console application to generate initial RBAC roles, permissions, and assignments. The console application also allows permitting/revoking a permission for a given role.
I’m using DbManager as my authManager and AppCache as my caching mechanism.
'cache' => [
'class' => 'yii\caching\ApcCache',
'keyPrefix' => 'counsellor'
],
...
'authManager' => [
'class' => 'common\components\rbac\DbManager',
'defaultRoles' => ['guest'], // Important - all roles inherit (accumulate) defaultRoles
'cache' => 'cache'
]
The issue I’m running into is I cannot invalidate the cache from the console; from the web is OK. For example, this is one of the methods that is called from a console action:
protected function _revoke($roleName, $permissionName)
{
$authManager = Yii::$app->authManager;
$role = $authManager->getRole($roleName);
if (!$role) {
throw new Exception(Yii::t('app', 'prefix:err_subject:noRole', array('roleName' => $roleName)));
}
$permission = $authManager->getPermission($permissionName);
$authManager->removeChild($role, $permission);
$authManager->invalidateCache();
}
[size="2"]The cache is never cleared. print_r($authManager->cache); from the console outputs the following:[/size]
ApcCache Object (
[keyPrefix] => counsellor
[serializer] =>
[_events] => array()
[size=“2”]which leads me to believe the cache isn’t fully [/size]initialized[size=“2”] yet. Has anyone run into this? Is it a problem with my configuration file?[/size]