Problem with issue_create_validate?

Post about your customizations to share with others.

Moderators: Developer, Contributor

Post Reply
bmason
Posts: 9
Joined: Aug 29, 2019 2:56 pm

Problem with issue_create_validate?

Post 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?

bmason
Posts: 9
Joined: Aug 29, 2019 2:56 pm

Re: Problem with issue_create_validate?

Post 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.

atrol
Site Admin
Posts: 7791
Joined: Mar 26, 2008 4:37 pm
Location: Germany

Re: Problem with issue_create_validate?

Post by atrol »

Code: Select all

custom_function_overrride_issue_create_validate
should be

Code: Select all

custom_function_override_issue_create_validate
Please use Search before posting and read the Manual

bmason
Posts: 9
Joined: Aug 29, 2019 2:56 pm

Re: Problem with issue_create_validate?

Post 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.

atrol
Site Admin
Posts: 7791
Joined: Mar 26, 2008 4:37 pm
Location: Germany

Re: Problem with issue_create_validate?

Post by atrol »

No worries, I had also to look more than one time to see what's wrong ...
Please use Search before posting and read the Manual

Post Reply