mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 22:32:40 +08:00
Fixes #12810: getChildRoles() throws an exception when role has no children
This commit is contained in:
committed by
Alexander Makarov
parent
f71a14c284
commit
73a30780b3
@ -5,6 +5,7 @@ Yii Framework 2 Change Log
|
|||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
- Bug #12791: Fixed `yii\behaviors\AttributeTypecastBehavior` unable to automatically detect `attributeTypes`, triggering PHP Fatal Error (klimov-paul)
|
- Bug #12791: Fixed `yii\behaviors\AttributeTypecastBehavior` unable to automatically detect `attributeTypes`, triggering PHP Fatal Error (klimov-paul)
|
||||||
|
- Bug #12810: Fixed `yii\rbac\DbManager::getChildRoles()` and `yii\rbac\PhpManager::getChildRoles()` throws an exception when role has no child roles (mysterydragon)
|
||||||
- Enh #12790: Added `scrollToErrorOffset` option for `ActiveForm` which adds ability to specify offset in pixels when scrolling to error (mg-code)
|
- Enh #12790: Added `scrollToErrorOffset` option for `ActiveForm` which adds ability to specify offset in pixels when scrolling to error (mg-code)
|
||||||
- Enh #12807: Added console controller checks for `yii\console\controllers\HelpController` (schmunk42)
|
- Enh #12807: Added console controller checks for `yii\console\controllers\HelpController` (schmunk42)
|
||||||
|
|
||||||
|
|||||||
@ -481,7 +481,7 @@ class DbManager extends BaseManager
|
|||||||
throw new InvalidParamException("Role \"$roleName\" not found.");
|
throw new InvalidParamException("Role \"$roleName\" not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var $result Item[] */
|
$result = [];
|
||||||
$this->getChildrenRecursive($roleName, $this->getChildrenList(), $result);
|
$this->getChildrenRecursive($roleName, $this->getChildrenList(), $result);
|
||||||
|
|
||||||
$roles = [$roleName => $role];
|
$roles = [$roleName => $role];
|
||||||
|
|||||||
@ -407,7 +407,7 @@ class PhpManager extends BaseManager
|
|||||||
throw new InvalidParamException("Role \"$roleName\" not found.");
|
throw new InvalidParamException("Role \"$roleName\" not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var $result Item[] */
|
$result = [];
|
||||||
$this->getChildrenRecursive($roleName, $result);
|
$this->getChildrenRecursive($roleName, $result);
|
||||||
|
|
||||||
$roles = [$roleName => $role];
|
$roles = [$roleName => $role];
|
||||||
|
|||||||
@ -223,6 +223,9 @@ abstract class ManagerTestCase extends TestCase
|
|||||||
$updateAnyPost->description = 'update any post';
|
$updateAnyPost->description = 'update any post';
|
||||||
$this->auth->add($updateAnyPost);
|
$this->auth->add($updateAnyPost);
|
||||||
|
|
||||||
|
$withoutChildren = $this->auth->createRole('withoutChildren');
|
||||||
|
$this->auth->add($withoutChildren);
|
||||||
|
|
||||||
$reader = $this->auth->createRole('reader');
|
$reader = $this->auth->createRole('reader');
|
||||||
$this->auth->add($reader);
|
$this->auth->add($reader);
|
||||||
$this->auth->addChild($reader, $readPost);
|
$this->auth->addChild($reader, $readPost);
|
||||||
@ -292,6 +295,11 @@ abstract class ManagerTestCase extends TestCase
|
|||||||
{
|
{
|
||||||
$this->prepareData();
|
$this->prepareData();
|
||||||
|
|
||||||
|
$roles = $this->auth->getChildRoles('withoutChildren');
|
||||||
|
$this->assertCount(1, $roles);
|
||||||
|
$this->assertInstanceOf(Role::className(), reset($roles));
|
||||||
|
$this->assertTrue(reset($roles)->name === 'withoutChildren');
|
||||||
|
|
||||||
$roles = $this->auth->getChildRoles('reader');
|
$roles = $this->auth->getChildRoles('reader');
|
||||||
$this->assertCount(1, $roles);
|
$this->assertCount(1, $roles);
|
||||||
$this->assertInstanceOf(Role::className(), reset($roles));
|
$this->assertInstanceOf(Role::className(), reset($roles));
|
||||||
|
|||||||
Reference in New Issue
Block a user