View Issue Details

IDProjectCategoryView StatusLast Update
0006676mantisbtbugtrackerpublic2015-04-05 05:51
Reporterfman Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Product Version1.0.0 
Summary0006676: Block Assignment if Assignee is empty
Description

Is possible to choose the empty option in the combo with the possible
assignee of an issue, resulting in an issue assigned to nobody.
IMHO this operation is not a valid one.
Would you mind to fix it or pointing me to info regarding the usefulness of
this kind of assignment.

regards

Tagspatch
Attached Files
status_and_handler_diff.txt (6,647 bytes)   
==== bug_update.php#2 (text) ====

@@ -75,11 +75,20 @@
 	$f_close_now					= gpc_get_string( 'close_now', false );
 
 	# Handle auto-assigning
-	if ( ( NEW_ == $t_bug_data->status )
-	  && ( 0 != $t_bug_data->handler_id )
-	  && ( ON == config_get( 'auto_set_status_to_assigned' ) ) ) {
-		$t_bug_data->status = config_get( 'bug_assigned_status' );
-	}
+    if( ON == config_get('auto_set_status_to_assigned') ) {
+        # Bugs that were still in status 'new' and have just had a handler
+        # set should be changed to 'assigned' status.
+        if( NEW_ == $t_old_bug_status && NEW_ == $t_bug_data->status && NO_USER != $t_bug_data->handler_id ) {
+            $t_bug_data->status = config_get( 'bug_assigned_status' );
+        }
+        # Bugs that were still in status 'assigned' and have just had their
+        # handler reset to none should go back into their initial status.
+        elseif( ASSIGNED == $t_old_bug_status && ASSIGNED == $t_bug_data->status && NO_USER == $t_bug_data->handler_id ) {
+            $t_bug_data->status = config_get( 'bug_submit_status' );
+        }
+        
+        # NB: Error cases should be picked up in the validation just below.
+    }
 
 	helper_call_custom_function( 'issue_update_validate', array( $f_bug_id, $t_bug_data, $f_bugnote_text ) );
 

==== core/bug_api.php#3 (text) ====

@@ -1081,25 +1081,33 @@
 		$h_status		= bug_get_field( $p_bug_id, 'status' );
 		$h_handler_id	= bug_get_field( $p_bug_id, 'handler_id' );
 
-		if ( ( ON == config_get( 'auto_set_status_to_assigned' ) ) &&
-			 ( NO_USER != $p_user_id ) ) {
-			$t_ass_val = config_get( 'bug_assigned_status' );
-		} else {
-			$t_ass_val = $h_status;
-		}
+        # Handle auto-assigning
+        $t_new_status = $h_status;
+        if( ON == config_get('auto_set_status_to_assigned') ) {
+            # Bugs that were still in status 'new' and have just had a handler
+            # set should be changed to 'assigned' status.
+            if( NEW_ == $h_status && NO_USER != $p_user_id ) {
+                $t_new_status = config_get( 'bug_assigned_status' );
+            }
+            # Bugs that were still in status 'assigned' and have just had their
+            # handler reset to none should go back into their initial status.
+            elseif( ASSIGNED == $h_status && NO_USER == $p_user_id ) {
+                $t_new_status = config_get( 'bug_submit_status' );
+            }
+        }
 
 		$t_bug_table = config_get( 'mantis_bug_table' );
 
-		if ( ( $t_ass_val != $h_status ) || ( $p_user_id != $h_handler_id ) ) {
+		if ( ( $t_new_status != $h_status ) || ( $p_user_id != $h_handler_id ) ) {
 
 			# get user id
 			$query = "UPDATE $t_bug_table
-					  SET handler_id='$c_user_id', status='$t_ass_val'
+					  SET handler_id='$c_user_id', status='$t_new_status'
 					  WHERE id='$c_bug_id'";
 			db_query( $query );
 
 			# log changes
-			history_log_event_direct( $c_bug_id, 'status', $h_status, $t_ass_val );
+			history_log_event_direct( $c_bug_id, 'status', $h_status, $t_new_status );
 			history_log_event_direct( $c_bug_id, 'handler_id', $h_handler_id, $p_user_id );
 
 			# Add bugnote if supplied

==== core/constant_inc.php#2 (text) ====

@@ -168,18 +168,19 @@
 	define( 'ERROR_ACCESS_DENIED',					13 );
 	define( 'ERROR_UPLOAD_FAILURE',					15 );
 	define( 'ERROR_FTP_CONNECT_ERROR',				16 );
-	define( 'ERROR_HANDLER_ACCESS_TOO_LOW',				17 );
+	define( 'ERROR_HANDLER_ACCESS_TOO_LOW',			17 );
 	define( 'ERROR_PAGE_REDIRECTION',				18 );
+    define( 'ERROR_STATUS_HANDLER_MISMATCH',        30 );
 
 	# ERROR_CONFIG_*
 	define( 'ERROR_CONFIG_OPT_NOT_FOUND',			100 );
-	define( 'ERROR_CONFIG_OPT_INVALID',			101 );
+	define( 'ERROR_CONFIG_OPT_INVALID',			    101 );
 
 	# ERROR_GPC_*
 	define( 'ERROR_GPC_VAR_NOT_FOUND',				200 );
 	define( 'ERROR_GPC_ARRAY_EXPECTED',				201 );
 	define( 'ERROR_GPC_ARRAY_UNEXPECTED',			202 );
-	define( 'ERROR_GPC_NOT_NUMBER',			203 );
+	define( 'ERROR_GPC_NOT_NUMBER',			        203 );
 
 	# ERROR_LANG_*
 	define( 'ERROR_LANG_STRING_NOT_FOUND',			300 );
@@ -196,7 +197,7 @@
 	define( 'ERROR_FILE_DUPLICATE',					502 );
 	define( 'ERROR_FILE_INVALID_UPLOAD_PATH',		503 );
 	define( 'ERROR_FILE_NO_UPLOAD_FAILURE',		    504 );
-	define( 'ERROR_FILE_MOVE_FAILED',		    505 );
+	define( 'ERROR_FILE_MOVE_FAILED',		        505 );
 
 	# ERROR_BUGNOTE_*
 	define( 'ERROR_BUGNOTE_NOT_FOUND',				600 );

==== core/custom_function_api.php#2 (text) ====

@@ -85,6 +85,25 @@
 	# p_issue_id is the issue number that can be used to get the existing state
 	# p_new_issue_data is an object (BugData) with the appropriate fields updated
 	function custom_function_default_issue_update_validate( $p_issue_id, $p_new_issue_data, $p_bugnote_text ) {
+        # Shouldn't be returning bugs to 'new' status if there's still a
+        # handler set.
+        if( NEW_ == $p_new_issue_data->status && NO_USER != $p_new_issue_data->handler_id ) {
+            trigger_error( ERROR_STATUS_HANDLER_MISMATCH, ERROR );
+        }
+        
+        # Similarly, shouldn't be changing a bug to be in certain statuses
+        # without also setting a handler.
+        if( NO_USER == $p_new_issue_data->handler_id ) {
+            switch( $p_new_issue_data->status ) {
+                case ASSIGNED:
+                case RESOLVED:
+                case CLOSED:
+                    trigger_error( ERROR_STATUS_HANDLER_MISMATCH, ERROR ); // Doesn't return.
+                    
+                default:
+                    break;
+            }
+        }
 	}
 
 	# --------------------

==== lang/strings_english.txt#3 (text) ====

@@ -258,6 +258,7 @@
 $MANTIS_ERROR[ERROR_PROJECT_RECURSIVE_HIERARCHY] = 'That operation would create a loop in the subproject hierarchy.';
 $MANTIS_ERROR[ERROR_USER_CHANGE_LAST_ADMIN] = 'You cannot change the access level of the only ADMINISTRATOR in the system.';
 $MANTIS_ERROR[ERROR_PAGE_REDIRECTION] = 'Page redirection error, ensure that there are no spaces outside the PHP block (<?php ?>) in config_inc.php or custom_*.php files.';
+$MANTIS_ERROR[ERROR_STATUS_HANDLER_MISMATCH] = 'This bug\'s status is incompatible with the handler setting. For example, a bug with \'assigned\' status must have a handler set.';
 
 #$s_login_error = 'Your account may be disabled or blocked (due to too many failed login attempts) or the username/password you entered is incorrect.';
 $s_login_error = 'Your account may be disabled or blocked or the username/password you entered is incorrect.';
status_and_handler_diff.txt (6,647 bytes)   

Relationships

related to 0006729 new Status of ASSIGNED may exist w/o an assignee 

Activities

stefanvandenoord

stefanvandenoord

2006-03-17 10:52

reporter   ~0012359

At my company, somebody incorrectly assigned a lot of issues. It need this option to reset the assignee to 'empty'.

stefanb

stefanb

2006-03-17 16:54

reporter   ~0012360

Duplicate of 0006729.

vboctor

vboctor

2006-03-21 06:31

manager   ~0012382

The empty entry in the "Assign To" combo-box should only appear if the issue is already assigned to a user. This way you can unassign the issue. If the issue is not assigned to a user, then you shouldn't get the empty option.

Does this make sense?

stefanvandenoord

stefanvandenoord

2006-03-23 15:35

reporter   ~0012402

It does make sense, as long as it is not dependent of the status of the bug: especially if the status is lower than assigned (confirmed, acknowledged, etc.), then it should be possible to unassign.

morganparry

morganparry

2006-08-14 05:10

reporter   ~0013263

As noted in the bug linked above, you can break this by using the main bug update page.

morganparry

morganparry

2006-08-14 10:17

reporter   ~0013265

Last edited: 2006-08-14 10:18

I've uploaded a diff against Mantis v1.0.5 in unified diff format that fixes the problem for us. It modifies the code to do the following:

  • Give an error message when trying to set a bug to be assigned, resolved or closed with no handler.
  • Give an error message when trying to set a bug back to new status with a handler set.
  • If a bug has assigned status and the handler is unset, put it back into the default initial status.

Note that I had to add a new string which would obviously require translation.

vijaymodi_81

vijaymodi_81

2009-03-12 08:58

reporter   ~0021036

I was facing the same problem. I debugged the code and found something interesting.
1> Create an issue and assigned to some user suppose "test".
2> User "test" resolves the issue and make that issue resolved.
3> Now "test" user is not working on this project and so Administrator has deleted his account.
3> Then tester test the issue and going to change status to "Assigned". And there the Assigned person was "test" and when Tester click on "Change Status To" button, he will get this error.

How to resolve?
To resolve this issue, please assigned that "test" user to that Project. Once Administrator will do that, tester can change status to "Assigned" and can assigned issue to "test" user.

Thanks & Regards,
Vijay Modi
http://vijaymodi.wordpress.com