Skip to content

Commit

Permalink
Allow bug update if original reporter missing
Browse files Browse the repository at this point in the history
Adding validation on reporter id caused Mantis to trigger error and
prevent bug update, when editing a bug and the user who reported it
no longer exists.

Issue #27350
  • Loading branch information
dregad committed Dec 30, 2020
1 parent 35fdf03 commit a528b60
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions bug_update.php
Expand Up @@ -119,14 +119,24 @@ function get_valid_version( BugData $p_bug, $p_field ) {
$t_updated_bug->projection = gpc_get_int( 'projection', $t_existing_bug->projection );

$t_reporter_id = gpc_get_int( 'reporter_id', $t_existing_bug->reporter_id );
user_ensure_exists( $t_reporter_id );
$t_can_report = access_has_project_level(
config_get( 'report_bug_threshold', null, $t_reporter_id, $t_existing_bug->project_id ),
$t_existing_bug->project_id,
$t_reporter_id
);
if( !$t_can_report ) {
trigger_error( ERROR_USER_DOES_NOT_HAVE_REQ_ACCESS, ERROR );
# Only validate the reporter if different from the recorded one; this avoids
# blocking the update when changing another field and the original reporter's
# account no longer exists.
if( $t_reporter_id != $t_existing_bug->reporter_id ) {
user_ensure_exists( $t_reporter_id );
$t_report_bug_threshold = config_get( 'report_bug_threshold',
null,
$t_reporter_id,
$t_existing_bug->project_id
);
$t_can_report = access_has_project_level(
$t_report_bug_threshold,
$t_existing_bug->project_id,
$t_reporter_id
);
if( !$t_can_report ) {
trigger_error( ERROR_USER_DOES_NOT_HAVE_REQ_ACCESS, ERROR );
}
}
$t_updated_bug->reporter_id = $t_reporter_id;

Expand Down

0 comments on commit a528b60

Please sign in to comment.