Page 1 of 1

Problem with issue_create_validate?

Posted: Oct 23, 2019 3:44 pm
by bmason
I am sorry to bother you. I know I am a noob but this is driving me crazy.

I successfully added this hook to my custom_function_inc.php file and it is working:

Code: Select all

/** * Hook to validate Validate field settings before resolving
  * verify that the Fixed In Version is set (if versions of the product exist) */ 

function custom_function_override_issue_update_validate( $p_issue_id, $p_bug_data, $p_bugnote_text ) {
 	if( $p_bug_data->status == RESOLVED ) {
  		
		$t_version_count = count( version_get_all_rows( $p_bug_data->project_id ) );
		if( ( $t_version_count > 0 ) && ( $p_bug_data->fixed_in_version == '' ) ) {
   			error_parameters( 'Fixed In Version' );
   			trigger_error( ERROR_EMPTY_FIELD, ERROR );  
		}
 	}
 }
Inspired by this success, I decided to make the Product Version field required when a user submits a new bug. In trying to debug this, I have commented out every line in the hook except the following:

Code: Select all

# Check to see if bug has Product Version set:
function custom_function_overrride_issue_create_validate( $p_new_issue_data ) { 
		error_parameters( 'product_version' );
		trigger_error( ERROR_EMPTY_FIELD, ERROR );	
}
I would expect that this would effectively prevent anyone from submitting bugs, but it has no effect whatsoever. It looks like this custom function isn't running at all (but as I said, the custom_function_override_issue_update_validate function, in the same file, is working). Is this a problem with my version of MantisBT (2.22.0), or have I messed something up?

Re: Problem with issue_create_validate?

Posted: Jan 06, 2020 1:05 pm
by bmason
I am a little disappointed that I have not heard from anyone about this issue, if only to tell me that my code was wrong.

I now have the following in my custom_functions_inc.php file, but it is still not working:

function custom_function_overrride_issue_create_validate( $p_new_issue_data ) {

if ( $p_new_issue_data->version == '' ) {
error_parameters( 'Product Version' );
trigger_error(ERROR_EMPTY_FIELD, ERROR );
}
}

It almost seems as if the custom function is never being invoked. Please, any advice would be greatly appreciated.

Re: Problem with issue_create_validate?

Posted: Jan 06, 2020 1:34 pm
by atrol

Code: Select all

custom_function_overrride_issue_create_validate
should be

Code: Select all

custom_function_override_issue_create_validate

Re: Problem with issue_create_validate?

Posted: Jan 06, 2020 2:50 pm
by bmason
Oh my goodness, thank you and sorry to bother you with such a stupid issue! I stared at that code a long time and never saw the extra r.

Re: Problem with issue_create_validate?

Posted: Jan 06, 2020 5:07 pm
by atrol
No worries, I had also to look more than one time to see what's wrong ...