Debugging of custom functions
Posted: 10 Jan 2018, 16:41
I'm a newbie with mantis coding and am trying to write a custom function to validate an update according to a set of rules. After much trial and error, I have the function being invoked when I click the update issue button but am struggling in figuring out how to access the values of several custom fields so that I can check to see if at least one of them contains a non-zero value, throwing an exception if not. Here is what I have
I know that I'm comparing the before and after status values but I can't tell what the retrieved custom field values are. In fact, the code shown is throwing a #1300 exception stating that the custom field name wasn't found. I've double checked the spelling both in my code and in the database table and they match exactly so I am speculating that I'm not using the function correctly or that I should be using another way to retrieve these values. Help would be appreciated here.
Basically, I need to know if there is some technique I can use to debug. I tried using printf statements but I don't know where the results are displayed and, AFAIK, there is no debugger (like GDB) which I can use to set breakpoints and examine variables.
Code: Select all
function custom_function_override_issue_update_validate( $p_issue_id, BugData $p_new_issue_data, $p_bugnote_text ) {
$t_issue = bug_get( $p_issue_id );
if ($t_issue->status == INVESTIGATE && $p_new_issue_data->status == Proposal) {
// Get the values for the fields
$annual_costs = custom_field_get_value('Estimated Annual Costs', $p_issue_id);
$est_hours = custom_field_get_value('Estimated Hours', $p_issue_id);
$est_costs = custom_field_get_value('Estimated Initial Costs', $p_issue_id);
// At least one of these fields must have a non-zero value, otherwise, throw
// an exception
if ($annual_costs == 0.0 && $est_hours == 0.0 && $est_costs == 0.0) {
error_parameters('this is testing to verify override function is activated');
trigger_error(ERROR_VALIDATE_FAILURE, ERROR);
}
}
}
Basically, I need to know if there is some technique I can use to debug. I tried using printf statements but I don't know where the results are displayed and, AFAIK, there is no debugger (like GDB) which I can use to set breakpoints and examine variables.