View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0006676 | mantisbt | bugtracker | public | 2006-02-06 13:30 | 2015-04-05 05:51 |
| Reporter | fman | Assigned To | |||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | new | Resolution | open | ||
| Product Version | 1.0.0 | ||||
| Summary | 0006676: Block Assignment if Assignee is empty | ||||
| Description | Is possible to choose the empty option in the combo with the possible regards | ||||
| Tags | patch | ||||
| 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.';
| ||||
| related to | 0006729 | new | Status of ASSIGNED may exist w/o an assignee |
|
At my company, somebody incorrectly assigned a lot of issues. It need this option to reset the assignee to 'empty'. |
|
|
Duplicate of 0006729. |
|
|
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? |
|
|
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. |
|
|
As noted in the bug linked above, you can break this by using the main bug update page. |
|
|
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:
Note that I had to add a new string which would obviously require translation. |
|
|
I was facing the same problem. I debugged the code and found something interesting. How to resolve? Thanks & Regards, |
|