Yii2 RBAC Redis - 什么错了?

问题描述 投票:0回答:1

我试图在我的Yii2高级应用程序中使用RBAC(sweetlix / yii2-redis-rbac和yiisoft / yii2-redis已安装)。

  1. 通用/ main.php: //.... 'components' => [ 'authManager' => [ 'class' => 'sweelix\rbac\redis\Manager', 'db' => 'redis', ], // ... ],
  2. 公共/主local.php: //.... 'components' => [ 'authManager' => [ 'class' => 'yii\redis\Connection', 'hostname' => 'localhost', 'port' => 6379, 'database' => 1, ], // ... ],
  3. 让我们尝试初始化(RbacController): public function actionInit() { $auth->removeAll(); $user = $auth->createRole('user'); $auth->add($user); $admin = $auth->createRole('admin'); $auth->add($admin); $auth->addChild($admin, $user); $auth->assign($admin, 1); // 1 - is id of admin user on database }

php yii rbac/init回归:

Error: Redis error: ERR wrong number of arguments for 'hget' command. Redis command was: HGET auth:mappings:rules 

物品转储:

    $user = $auth->createRole('user');
    var_dump($user);die;

收益:

    object(yii\rbac\Role)#21 (7) {
      ["type"]=> int(1)
      ["name"]=> string(4) "user"
      ["description"]=> NULL
      ["ruleName"]=> NULL
      ["data"]=> NULL
      ["createdAt"]=> NULL
      ["updatedAt"]=> NULL
    }

第364行的sweelix \ rbac \ redisManager:如果$ item-> ruleName为null,我们有错误...

$ruleGuid = $this->db->executeCommand('HGET', [$this->getRuleMappingKey(), $item->ruleName]);

弗斯:

Redis server v=3.2.6"yiisoft/yii2": "~2.0.14"yiisoft/yii2-redis 2.0.8PHP 7.0.33

redis yii2 yii2-advanced-app rbac yii2-rbac
1个回答
0
投票

我在其他应用程序和环境中检查过它,并注意到它适用于版本"yiisoft/yii2-redis": "2.0.8""yiisoft/yii2-redis": "2.0.9"它会产生错误(第364行的sweelix \ rbac \ redisManager:$ruleGuid = $this->db->executeCommand('HGET', [$this->getRuleMappingKey(), $item->ruleName]);)。如果强行切换到软件包的“2.0.8”版本,则错误消失。

© www.soinside.com 2019 - 2024. All rights reserved.