View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0008663 | mantisbt | sub-projects | public | 2007-12-10 04:23 | 2019-04-07 13:31 |
Reporter | sveyret | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | new | Resolution | open | ||
Product Version | 1.0.8 | ||||
Summary | 0008663: Multiparent projects not prune in project list | ||||
Description | The error is in core/core_api.php, function user_get_accessible_projects. When a project has more than one parent, the prune part does not work properly. I made small changes between $t_projects = array(); and foreach ( $t_prune as $t_id ) { Here is the new code: for ( $i=0 ; $i < $row_count ; $i++ ) {
} prune out children where the parents are already listed. Make the listfirst, then prune to avoid pruning a parent before the child is found.t_prune = array(); Hope this can help you. | ||||
Steps To Reproduce | Imagine we have 2 projects with a UI part and a engine part. We will have 4 mantis projects: Proj1UI, Proj1Engine, Proj2UI, Proj2Engine. We need to access these project in a vertical way (i.e. full project) but also, as they actually are modules of a big platform, in horizontal way (i.e. all UI or all engines). We then create 4 more projects: Proj1, parent of Proj1UI and Proj1Engine. Now, if someone, for example, has rights on Proj1UI and UI, but not on Proj1, the project Proj1UI should be only displayed inside parent project UI. Actually, it may display twice (it depends on the order of the DB query result), once alone, and once inside the UI parent. | ||||
Tags | patch | ||||
Attached Files | user_api.patch (735 bytes)
736c736,740 < $t_projects[ $row['id'] ] = ( $row['parent_id'] === NULL ) ? 0 : $row['parent_id']; --- > if ( !isset ( $t_projects[ $row['id'] ] ) ) { > $t_projects[ $row['id'] ] = array(); > } > > $t_projects[ $row['id'] ][] = ( $row['parent_id'] === NULL ) ? 0 : $row['parent_id']; 742,744c746,751 < foreach ( $t_projects as $t_id => $t_parent ) { < if ( ( $t_parent !== 0 ) && isset( $t_projects[$t_parent] ) ) { < $t_prune[] = $t_id; --- > foreach ( $t_projects as $t_id => $t_parent_list ) { > foreach ( $t_parent_list as $t_parent ) { > if ( ( $t_parent !== 0 ) && isset( $t_projects[$t_parent] ) ) { > if ( !in_array ( $t_id, $t_prune ) ) > $t_prune[] = $t_id; > } issue8663.patch (1,511 bytes)
From afaec9f5f9c26df0d46ef0eaa7481f2e82cf6861 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?St=82phane=20Veyret?= <sveyret@axway.com> Date: Wed, 1 Jul 2009 09:57:23 +0200 Subject: [PATCH] Fix 0008663: Multiparent projects not prune in project list --- core/user_api.php | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/user_api.php b/core/user_api.php index 23dbb45..be17388 100644 --- a/core/user_api.php +++ b/core/user_api.php @@ -748,15 +748,22 @@ for ( $i=0 ; $i < $row_count ; $i++ ) { $row = db_fetch_array( $result ); - $t_projects[ $row['id'] ] = ( $row['parent_id'] === NULL ) ? 0 : $row['parent_id']; + if ( !isset ( $t_projects[ $row['id'] ] ) ) { + $t_projects[ $row['id'] ] = array(); + } + + $t_projects[ $row['id'] ][] = ( $row['parent_id'] === NULL ) ? 0 : $row['parent_id']; } # prune out children where the parents are already listed. Make the list # first, then prune to avoid pruning a parent before the child is found. $t_prune = array(); - foreach ( $t_projects as $t_id => $t_parent ) { - if ( ( $t_parent !== 0 ) && isset( $t_projects[$t_parent] ) ) { - $t_prune[] = $t_id; + foreach ( $t_projects as $t_id => $t_parent_list ) { + foreach ( $t_parent_list as $t_parent ) { + if ( ( $t_parent !== 0 ) && isset( $t_projects[$t_parent] ) ) { + if ( !in_array ( $t_id, $t_prune ) ) + $t_prune[] = $t_id; + } } } foreach ( $t_prune as $t_id ) { -- 1.6.3.2 | ||||
related to | 0025641 | new | Refactor project hierarchy |
This issue is still true in version 1.1.1, but the function is now in the file user_api.php. |
|
I added the patch for branch 1.1.x. |
|
I tried to use the code for my problem but it didn't work. If i have a project that has a parent and a grandparent, for example, the child project apperas on the list out of the tree projects. |
|
Thank you very much for finding a patch for this. The bug is still present in 1.2.8 and hit me with a similiar setup. |
|