Skip to content

Commit

Permalink
Check workflow prior to reopening bug
Browse files Browse the repository at this point in the history
Add a check to access_can_reopen_bug() to ensure the reopen status is
reachable by the current workflow configuration. If not, return false.

Previously, the reopen operation would fail anyway when the status is
changed. With this early check, failure is detected before the action is
made.

A direct benefit from this is that the "reopen" button is not shown to
the user if the action is not possible.

Fixes #20256

Signed-off-by: Damien Regad <dregad@mantisbt.org>
  • Loading branch information
cproensa authored and dregad committed Dec 20, 2015
1 parent 770df68 commit 9eb915c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/access_api.php
Expand Up @@ -560,6 +560,13 @@ function access_can_reopen_bug( BugData $p_bug, $p_user_id = null ) {
$p_user_id = auth_get_current_user_id();
}

$t_reopen_status = config_get( 'bug_reopen_status', null, null, $p_bug->project_id );

# Reopen status must be reachable by workflow
if( !bug_check_workflow( $p_bug->status, $t_reopen_status ) ) {
return false;
}

# If allow_reporter_reopen is enabled, then reporters can always reopen
# their own bugs as long as their access level is reporter or above
if( ON == config_get( 'allow_reporter_reopen', null, null, $p_bug->project_id )
Expand All @@ -572,7 +579,6 @@ function access_can_reopen_bug( BugData $p_bug, $p_user_id = null ) {
# Other users's access level must allow them to reopen bugs
$t_reopen_bug_threshold = config_get( 'reopen_bug_threshold', null, null, $p_bug->project_id );
if( access_has_bug_level( $t_reopen_bug_threshold, $p_bug->id, $p_user_id ) ) {
$t_reopen_status = config_get( 'bug_reopen_status', null, null, $p_bug->project_id );

# User must be allowed to change status to reopen status
$t_reopen_status_threshold = access_get_status_threshold( $t_reopen_status, $p_bug->project_id );
Expand Down

0 comments on commit 9eb915c

Please sign in to comment.