Skip to content

Commit

Permalink
Refactoring project_hierarchy_get_parent()
Browse files Browse the repository at this point in the history
Renaming foreach variables to self-document their purpose.

Derefencing $g_cache_project_hierarchy is not necessary, since we
already have the child projects in the foreach's value variable.
  • Loading branch information
dregad committed Mar 15, 2020
1 parent e8738fc commit e0a1168
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/project_hierarchy_api.php
Expand Up @@ -131,9 +131,9 @@ function project_hierarchy_get_parent( $p_project_id, $p_show_disabled = false )
return 0;
}

foreach( $g_cache_project_hierarchy as $t_key => $t_value ) {
if( in_array( $p_project_id, $g_cache_project_hierarchy[$t_key] ) ) {
return $t_key;
foreach( $g_cache_project_hierarchy as $t_parent_id => $t_child_projects ) {
if( in_array( $p_project_id, $t_child_projects ) ) {
return $t_parent_id;
}
}

Expand Down

0 comments on commit e0a1168

Please sign in to comment.