Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
Add some temporary error handling if group relationships are not found
Browse files Browse the repository at this point in the history
Pending further investigation and a refactoring of the module
  • Loading branch information
dwkitchen committed Jul 31, 2020
1 parent b62b630 commit 42115e2
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/GroupRoleInheritance.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,10 @@ protected function build($gid) {

// Get mapped roles for relation type. Filter array to remove
// unmapped roles.
$relation_config = $this->getSubgroupRelationConfig($path_supergroup_id, $path_subgroup_id);
$path_role_map[$path_supergroup_id][$path_subgroup_id] = array_filter($relation_config['child_role_mapping']);
$path_role_map[$path_subgroup_id][$path_supergroup_id] = array_filter($relation_config['parent_role_mapping']);
if ($relation_config = $this->getSubgroupRelationConfig($path_supergroup_id, $path_subgroup_id)) {
$path_role_map[$path_supergroup_id][$path_subgroup_id] = array_filter($relation_config['child_role_mapping']);
$path_role_map[$path_subgroup_id][$path_supergroup_id] = array_filter($relation_config['parent_role_mapping']);
}
}
$role_map[] = $path_role_map;

Expand Down Expand Up @@ -210,9 +211,9 @@ protected function mapIndirectPathRoles(array $path, array $path_role_map) {
continue;
}

$direct_role_map = $path_role_map[$path_to_group_id][$path_direct_to_group_id];
$direct_role_map = isset($path_role_map[$path_to_group_id][$path_direct_to_group_id]) ? $path_role_map[$path_to_group_id][$path_direct_to_group_id] : NULL;

if (empty($inherited_roles_map)) {
if (empty($inherited_roles_map) && isset($direct_role_map)) {
$inherited_roles_map = $direct_role_map;
}

Expand Down Expand Up @@ -281,8 +282,8 @@ protected function getSubgroupRelationConfig($group_id, $subgroup_id) {
}
}

$type = $this->subgroupRelations[$group_id][$subgroup_id];
return $subgroup_relations_config[$type];
$type = isset($this->subgroupRelations[$group_id][$subgroup_id]) ? $this->subgroupRelations[$group_id][$subgroup_id] : NULL;
return isset($subgroup_relations_config[$type]) ? $subgroup_relations_config[$type] : NULL;
}

}

0 comments on commit 42115e2

Please sign in to comment.