Skip to content

Commit

Permalink
Fix #11758: Improve handling of reassign on feedback feature
Browse files Browse the repository at this point in the history
The bugnote_add() function in bugnote_api.php is currently the only way
(using the API) to add a bugnote into the database. This function was
also attempting to handle the reassign on feedback feature. This posed
a problem because there are times that the bugnote_add() function needs
to be called without considering the reassign on feedback feature. For
example, importing issues from an XML file.

The bugnote_add() function has been changed to no longer handle the
reassign on feedback feature. The resposibility for handling this
feature now belongs within the scripts calling the bugnote_add()
function. The caller scripts are in a much better position to determine
how the reassign on feedback issue will be handled.
  • Loading branch information
davidhicks committed Aug 14, 2010
1 parent 596097f commit b6a2721
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
1 change: 1 addition & 0 deletions bug_update.php
Expand Up @@ -311,6 +311,7 @@
if ( $t_bug_note->note &&
config_get( 'reassign_on_feedback' ) &&
$t_existing_bug->status === config_get( 'bug_feedback_status' ) &&
$t_updated_bug->status <= config_get( 'bug_feedback_status' ) &&
$t_updated_bug->reporter_id === auth_get_current_user_id() ) {
if ( $t_updated_bug->handler_id !== NO_USER ) {
$t_updated_bug->status = config_get( 'bug_assigned_status' );
Expand Down
27 changes: 21 additions & 6 deletions bugnote_add.php
Expand Up @@ -63,25 +63,40 @@
$g_project_override = $t_bug->project_id;
}

if ( bug_is_readonly( $f_bug_id ) ) {
error_parameters( $f_bug_id );
if ( bug_is_readonly( $t_bug->id ) ) {
error_parameters( $t_bug->id );
trigger_error( ERROR_BUG_READ_ONLY_ACTION_DENIED, ERROR );
}

access_ensure_bug_level( config_get( 'add_bugnote_threshold' ), $f_bug_id );
access_ensure_bug_level( config_get( 'add_bugnote_threshold' ), $t_bug->id );

if ( $f_private ) {
access_ensure_bug_level( config_get( 'set_view_status_threshold' ), $f_bug_id );
access_ensure_bug_level( config_get( 'set_view_status_threshold' ), $t_bug->id );
}

// We always set the note time to BUGNOTE, and the API will overwrite it with TIME_TRACKING
// if $f_time_tracking is not 0 and the time tracking feature is enabled.
$t_bugnote_id = bugnote_add( $f_bug_id, $f_bugnote_text, $f_time_tracking, $f_private, BUGNOTE );
$t_bugnote_id = bugnote_add( $t_bug->id, $f_bugnote_text, $f_time_tracking, $f_private, BUGNOTE );
if ( !$t_bugnote_id ) {
error_parameters( lang_get( 'bugnote' ) );
trigger_error( ERROR_EMPTY_FIELD, ERROR );
}

# Handle the reassign on feedback feature. Note that this feature generally
# won't work very well with custom workflows as it makes a lot of assumptions
# that may not be true. It assumes you don't have any statuses in the workflow
# between 'bug_submit_status' and 'bug_feedback_status'. It assumes you only
# have one feedback, assigned and submitted status.
if ( config_get( 'reassign_on_feedback' ) &&
$t_bug->status === config_get( 'bug_feedback_status' ) &&
$t_bug->reporter_id === auth_get_current_user_id() ) {
if ( $t_bug->handler_id !== NO_USER ) {
bug_set_field( $t_bug->id, 'status', config_get( 'bug_assigned_status' ) );
} else {
bug_set_field( $t_bug->id, 'status', config_get( 'bug_submit_status' ) );
}
}

form_security_purge( 'bugnote_add' );

print_successful_redirect_to_bug( $f_bug_id );
print_successful_redirect_to_bug( $t_bug->id );
12 changes: 0 additions & 12 deletions core/bugnote_api.php
Expand Up @@ -210,18 +210,6 @@ function bugnote_add( $p_bug_id, $p_bugnote_text, $p_time_tracking = '0:00', $p_
# log new bug
history_log_event_special( $p_bug_id, BUGNOTE_ADDED, bugnote_format_id( $t_bugnote_id ) );

# if it was FEEDBACK its NEW_ now
if ( config_get( 'reassign_on_feedback' ) &&
bug_get_field( $p_bug_id, 'status' ) == config_get( 'bug_feedback_status' ) &&
bug_get_field( $p_bug_id, 'reporter_id' ) == $c_user_id ) {

if ( bug_get_field( $p_bug_id, 'handler_id') == 0 ) {
bug_set_field( $p_bug_id, 'status', config_get( 'bug_submit_status' ) );
} else {
bug_set_field( $p_bug_id, 'status', config_get( 'bug_assigned_status' ) );
}
}

# Event integration
event_signal( 'EVENT_BUGNOTE_ADD', array( $p_bug_id, $t_bugnote_id ) );

Expand Down

0 comments on commit b6a2721

Please sign in to comment.