MantisBT: master e8738fc0

Author Committer Branch Timestamp Parent
dregad dregad master 2020-03-09 04:26 master 2a42ea38
Affected Issues  0026765: Inheritance of sub project not read correctly from database
Changeset

Build project Inheritance cache as a map

project_hierarchy_cache() was inconsistent when processing the
$g_cache_project_inheritance array:

  • used as a list when inserting values, which creates sequential numeric
    keys (i.e. $cache[$t_project_id][] = $t_parent_id)
  • treated as a map when checking for value's existence
    (i.e. isset( $cache[$t_project_id][$t_parent_id'] )

The consequence is that we're effectively comparing apples and oranges
(e.g. project id 1 vs an unrelated array index key 1).

Consistently treating the array as a map (i.e. using the parent id as
key) allows for simpler and more efficient code, as we can just assign
the value without needing to call isset() or in_array() first.

Fixes 0026765

mod - core/project_hierarchy_api.php Diff File