View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0026765 | mantisbt | bugtracker | public | 2020-03-09 04:47 | 2020-03-15 15:23 |
Reporter | user37337 | Assigned To | dregad | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 2.23.0 | ||||
Target Version | 2.24.0 | Fixed in Version | 2.24.0 | ||
Summary | 0026765: Inheritance of sub project not read correctly from database | ||||
Description | Hi,
The problem here was the Maybe there are more such problems in this function because there are more isset uses for integers but I'm not a PHP guru so someone else should look for it. | ||||
Tags | No tags attached. | ||||
I'm not sure I fully understand the problem. Could you please explain what you do, what you expect to get and the results actually get, and provide detailed, step-by-step instructions to reproduce the issue. |
|
I'm not sure how to reproduce the problem with a new installation. The problem seems to occur when there are more than one parent project for some sub-projects. The while loop added a new row to $g_cache_project_inheritance with key value 2. |
|
Thanks for the feedback, now that I understand that you're using multiple inheritance (i.e. a single subproject with several parents), I am able to reproduce the problem. The root cause is that when are not consistent when accessing and updating the cache array: sometimes it is treated as a list (i.e. The consequence is that we're effectively comparing apples and oranges (i.e. project id 1 vs an unrelated array index key 1, corresponding to another project). Using in_array() would indeed fix the problem, but considering that we are already using the cache array as a map for the ALL_PROJECTS case, I think we should be consistent and do the same for other projects. This has an added benefit of being more efficient, as dereferncing the array |
|
Thank you, |
|
MantisBT: master e8738fc0 2020-03-09 04:26 Details Diff |
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 |
Affected Issues 0026765 |
|
mod - core/project_hierarchy_api.php | Diff File |