View Issue Details

IDProjectCategoryView StatusLast Update
0016122mantisbtbugtrackerpublic2013-07-01 03:19
ReporterMarcL Assigned To 
PrioritylowSeverityminorReproducibilityalways
Status acknowledgedResolutionopen 
Product Version1.2.15 
Summary0016122: Category is defaulted when moving issue to project inheriting fitting category
Description

If an issue with category GUI is moved from Project A to Project B (where both have the category defined as non-global and at least Project B does not define but inherit the category), then the issue will get the configured default category, due to the changes for 0012667.

A proposal to fix this:

traverse the project hierarchy starting with the target project until either

  • a category with equal name has been found
  • the top-level project has been reached with out finding a category with equal name
  • the current project does not inherit categories from it's parent
Tagspatch
Attached Files
16122.patch (1,378 bytes)   
diff --git a/core/bug_api.php b/core/bug_api.php
index 06bc514..f2328a1 100644
--- a/core/bug_api.php
+++ b/core/bug_api.php
@@ -1107,6 +1107,15 @@ function bug_move( $p_bug_id, $p_target_project_id ) {
 			// Map by name
 			$t_category_name = category_get_field( $t_category_id, 'name' );
 			$t_target_project_category_id = category_get_id_by_name( $t_category_name, $p_target_project_id, /* triggerErrors */ false );
+                        while ( $t_target_project_category_id === false && 
+                                !project_hierarchy_is_toplevel($p_target_project_id))
+                        {
+                                $p_parent_project_id = project_hierarchy_get_parent($p_target_project_id);
+                                if (!project_hierarchy_inherit_parent( $p_target_project_id, $p_parent_project_id ))
+                                   break;
+                                $p_target_project_id = $p_parent_project_id;
+                                $t_target_project_category_id = category_get_id_by_name( $t_category_name, $p_target_project_id, /* triggerErrors */ false );                        
+                        }
 			if ( $t_target_project_category_id === false ) {
 				// Use default category after moves, since there is no match by name.
 				$t_target_project_category_id = config_get( 'default_category_for_moves' );
16122.patch (1,378 bytes)   

Activities