Require second person to close issue

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
MarcS
Posts: 2
Joined: 27 Apr 2023, 08:22

Require second person to close issue

Post by MarcS »

I found this thread of 2016 which exactly describes my problem:

How can I enforce a two-man rule for closing issues?
viewtopic.php?t=23884

However, using the Search function didn't find any other threads regarding this.
Is this now built-in or do you still need to implement such rule as plug-in?

User memberlist.php?mode=viewprofile&u=31913 who announced to write such plugin has only ever written 4 posts in this forum (all in this thread), and then never came back.

Marc
cas
Posts: 1581
Joined: 11 Mar 2006, 16:08
Contact:

Re: Require second person to close issue

Post by cas »

You can achieve this in the following way:
using both status RESOLVED and CLOSED, all it then takes is to arrange that the one that resolved the issue, cannot close the issue.
Clearly you need to adjust the workflow that you can only select status "Closed" when it has status "Resolved".
Now this is not yet available in Mantis and would require a plugin to take care of this.

In case you already have another purpose for status " Resolved" , you can add another status , let's say "pre-closed" and handle the request in the saem way as above.
cas
Posts: 1581
Joined: 11 Mar 2006, 16:08
Contact:

Re: Require second person to close issue

Post by cas »

Actually you also can achieve this without a plugin using workflow threshold by giving the final status to the manager and the first closing status to a level below. Downside here is that the one doing the final status will be in a position to set the first closing statis too :roll:
MarcS
Posts: 2
Joined: 27 Apr 2023, 08:22

Re: Require second person to close issue

Post by MarcS »

cas wrote: 28 Apr 2023, 08:48 using both status RESOLVED and CLOSED, all it then takes is to arrange that the one that resolved the issue, cannot close the issue.
Exactly. Mantis should support this Feature ootb IMHO.
Clearly you need to adjust the workflow that you can only select status "Closed" when it has status "Resolved".
Yes. The issue lifecycle says:
<<an issue can be called as resolved for “fixed”, “duplicate”, “won’t fix”, “no change required”, or other reasons>>
It does make sense IMHO that you first resolve an issue (even with “won’t fix” but hopefully document the reason) and then close it.
Now this is not yet available in Mantis and would require a plugin to take care of this.
Bummer.
In that 2016 thread I mentioned above, the guys wanted to write such plugin. Ever heard of it?
In case you already have another purpose for status " Resolved" , you can add another status , let's say "pre-closed" and handle the request in the saem way as above.
Adding more complexity is not desirable.
Actually you also can achieve this without a plugin using workflow threshold by giving the final status to the manager and the first closing status to a level below. Downside here is that the one doing the final status will be in a position to set the first closing statis too
In our case, every other developer and also the reporter or testers should be able to close an issue - just not the person who resolved it.
So it is not about a hierarchy, but just to assure that it's always a two-persons operation.

Simple principle:
One person must resolve first
Any other person can then close
Only resolved issues can be closed
cas
Posts: 1581
Joined: 11 Mar 2006, 16:08
Contact:

Re: Require second person to close issue

Post by cas »

well here is some code which you could insert in the function bug_close within bug_api.php.
So insert the following code

Code: Select all

## first check if issue has correct status
$query1 	= "select status from {bug} where bug_id = $p_bug_id";
$result1	= db_query( $query1 );
$row1	= db_fetch_array( $result1 );
## has the issue the status resolved?
if ( $row1['status'] == 80 ){
	## fetch user-id who gave the bug this status
	$query2	= "select user_id from {bug_history} where bug_id = $p_bug_id and field_name= "status" and new_value=80 order by date_modified desc limit 1";
	$result2	= db_query( $query2 );
	$count2	= db_num_rows( $result2 );
	if ( $count2 >0 ){
		## if the same as who resolved it, trigger error
		$row2	= db_fetch_array( $result2 );
		if ( auth_get_current_user_id() ==  $row2['user_id'] ) {
			trigger_error( 'You also resolved the issue hence you cannot close it', ERROR );
		}
	} 
} else {
		trigger_error( 'The issue does not have status resolved', ERROR );
}
just after

Code: Select all

function bug_close( $p_bug_id, $p_bugnote_text = '', $p_bugnote_private = false, $p_time_tracking = '0:00' ) {
this of course needs to be packed as a plugin (which will require a small modification of a core mantis script) but think it is usable like this :mrgreen:
Post Reply