View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0006830 | mantisbt | customization | public | 2006-03-09 10:13 | 2019-05-14 09:42 |
| Reporter | Darkness | Assigned To | vboctor | ||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | closed | Resolution | fixed | ||
| Product Version | 1.0.0rc5 | ||||
| Fixed in Version | 1.1.0a3 | ||||
| Summary | 0006830: custom_function_override_issue_delete_notify and custom_function_override_issue_update_notify are not being triggered | ||||
| Description | When I create the following functions in custom_functions_inc.php: the first 2 are never called, I verified it by putting | ||||
| Additional Information | FIX: bugnote_add.php: 49 before print_successful_redirect_to_bug add: I first tried adding the fix for delete to bug_delete.php but that does not seem to work. | ||||
| Tags | No tags attached. | ||||
| Attached Files | 6830.diff (9,175 bytes)
Index: bug_actiongroup.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/bug_actiongroup.php,v
retrieving revision 1.49
diff -u -r1.49 bug_actiongroup.php
--- bug_actiongroup.php 16 Dec 2006 20:12:55 -0000 1.49
+++ bug_actiongroup.php 7 Feb 2007 05:15:20 -0000
@@ -62,7 +62,10 @@
if ( access_can_close_bug( $t_bug_id ) &&
( $t_status < CLOSED ) &&
bug_check_workflow($t_status, CLOSED) ) {
+
+ # @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $f_bug_id, $t_bug_data, $f_bugnote_text ) );
bug_close( $t_bug_id );
+ helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
} else {
if ( ! access_can_close_bug( $t_bug_id ) ) {
$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
@@ -82,8 +85,10 @@
case 'MOVE':
if ( access_has_bug_level( config_get( 'move_bug_threshold' ), $t_bug_id ) ) {
+ # @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
$f_project_id = gpc_get_int( 'project_id' );
bug_set_field( $t_bug_id, 'project_id', $f_project_id );
+ helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
} else {
$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
}
@@ -112,7 +117,9 @@
if ( access_has_bug_level( $t_threshold , $t_bug_id, $f_assign ) &&
access_has_bug_level( config_get( 'update_bug_assign_threshold', config_get( 'update_bug_threshold' ) ), $t_bug_id ) &&
bug_check_workflow($t_status, $t_assign_status ) ) {
+ # @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
bug_assign( $t_bug_id, $f_assign );
+ helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
} else {
if ( bug_check_workflow($t_status, $t_assign_status ) ) {
$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
@@ -129,7 +136,9 @@
bug_check_workflow($t_status, $t_resolved_status ) ) {
$f_resolution = gpc_get_int( 'resolution' );
$f_fixed_in_version = gpc_get_string( 'fixed_in_version', '' );
+ # @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
bug_resolve( $t_bug_id, $f_resolution, $f_fixed_in_version );
+ helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
} else {
if ( ( $t_status < $t_resolved_status ) &&
bug_check_workflow($t_status, $t_resolved_status ) ) {
@@ -143,7 +152,9 @@
case 'UP_PRIOR':
if ( access_has_bug_level( config_get( 'update_bug_threshold' ), $t_bug_id ) ) {
$f_priority = gpc_get_int( 'priority' );
+ # @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
bug_set_field( $t_bug_id, 'priority', $f_priority );
+ helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
} else {
$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
}
@@ -154,7 +165,9 @@
$t_project = bug_get_field( $t_bug_id, 'project_id' );
if ( access_has_bug_level( access_get_status_threshold( $f_status, $t_project ), $t_bug_id ) ) {
if ( TRUE == bug_check_workflow($t_status, $f_status ) ) {
+ # @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
bug_set_field( $t_bug_id, 'status', $f_status );
+ helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
} else {
$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_status' );
}
@@ -168,7 +181,9 @@
$t_project = bug_get_field( $t_bug_id, 'project_id' );
if ( access_has_bug_level( config_get( 'update_bug_threshold' ), $t_bug_id ) ) {
if ( category_exists( $t_project, $f_category ) ) {
+ # @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
bug_set_field( $t_bug_id, 'category', $f_category );
+ helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
} else {
$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_category' );
}
@@ -183,7 +198,9 @@
if ( access_has_bug_level( config_get( 'update_bug_threshold' ), $t_bug_id ) ) {
if ( version_exists( $t_project_id, $f_version ) ) {
+ # @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
bug_set_field( $t_bug_id, 'fixed_in_version', $f_fixed_in_version );
+ helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
} else {
$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_failed' );
}
@@ -196,7 +213,9 @@
if ( access_has_bug_level( config_get( 'roadmap_view_threshold' ), $t_bug_id ) ) {
if ( version_exists( $t_project_id, $f_version ) ) {
+ # @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
bug_set_field( $t_bug_id, 'target_version', $f_fixed_in_version );
+ helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
} else {
$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_failed' );
}
@@ -206,7 +225,9 @@
case 'VIEW_STATUS':
if ( access_has_bug_level( config_get( 'change_view_status_threshold' ), $t_bug_id ) ) {
$f_view_status = gpc_get_int( 'view_status' );
+ # @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
bug_set_field( $t_bug_id, 'view_state', $f_view_status );
+ helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
} else {
$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
}
@@ -216,7 +237,9 @@
if ( access_has_bug_level( config_get( 'set_bug_sticky_threshold' ), $t_bug_id ) ) {
$f_sticky = bug_get_field( $t_bug_id, 'sticky' );
// The new value is the inverted old value
+ # @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
bug_set_field( $t_bug_id, 'sticky', intval( !$f_sticky ) );
+ helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
} else {
$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
}
@@ -227,9 +250,11 @@
trigger_error( ERROR_GENERIC, ERROR );
}
+ # @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
$t_form_var = "custom_field_$f_custom_field_id";
$t_custom_field_value = gpc_get_custom_field( $t_form_var, $t_custom_field_def['type'], null );
custom_field_set_value( $f_custom_field_id, $t_bug_id, $t_custom_field_value );
+ helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
break;
default:
Index: bug_delete.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/bug_delete.php,v
retrieving revision 1.40
diff -u -r1.40 bug_delete.php
--- bug_delete.php 25 Jul 2005 16:34:10 -0000 1.40
+++ bug_delete.php 7 Feb 2007 05:01:05 -0000
@@ -35,11 +35,7 @@
$t_bug = bug_get( $f_bug_id, true );
- helper_call_custom_function( 'issue_delete_validate', array( $f_bug_id ) );
-
bug_delete( $f_bug_id );
- helper_call_custom_function( 'issue_delete_notify', array( $f_bug_id ) );
-
print_successful_redirect( 'view_all_bug_page.php' );
?>
Index: core/bug_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/bug_api.php,v
retrieving revision 1.103
diff -u -r1.103 bug_api.php
--- core/bug_api.php 12 Dec 2006 18:26:29 -0000 1.103
+++ core/bug_api.php 7 Feb 2007 05:00:47 -0000
@@ -662,11 +662,19 @@
$t_bug_table = config_get( 'mantis_bug_table' );
$t_bug_text_table = config_get( 'mantis_bug_text_table' );
+ # call pre-deletion custom function
+ helper_call_custom_function( 'issue_delete_validate', array( $p_bug_id ) );
+
# log deletion of bug
history_log_event_special( $p_bug_id, BUG_DELETED, bug_format_id( $p_bug_id ) );
email_bug_deleted( $p_bug_id );
+ # call post-deletion custom function. We call this here to allow the custom function to access the details of the bug before
+ # they are deleted from the database given it's id. The other option would be to move this to the end of the function and
+ # provide it with bug data rather than an id, but this will break backward compatibility.
+ helper_call_custom_function( 'issue_delete_notify', array( $f_bug_id ) );
+
# Unmonitor bug for all users
bug_unmonitor( $p_bug_id, null );
| ||||
| related to | 0025757 | acknowledged | Custom function on Move ( bug action group ) |
|
sorry, category should be customization |
|
|
after taking a closer look, the fix for custom_function_override_issue_delete_notify is not good. It should come before the bug_delete command, otherwise a non existant bug_id will be passed to the custom function. |
|
|
I also stumbled across this problem today, while trying to integrate Mantis with another system via e-mail. IMHO helper_call_custom_function( 'issue_update_notify', array( $f_bug_id ) ); Thanks for the hint, anyway :) |
|
|
you are absolutely right. |
|
|
On second thought, it probably would make more sense to call custom function hooks directly from the Mantis API instead of the view pages, i.e. core/bug_api.php and core/bugnote_api.php rather than bug_add/_update/etc. Maybe bugnotes should have their own verify and update hooks as well. |
|
|
I've attached a patch that does the following:
Challenge:
More work to be done:
Please test the attached patch and let me know if you find issues with it. I didn't really test it yet. Also let me know if you think of other scenarios that are missing. |
|
|
I will mark this issue as resolved. We can open new issues for any other changes that we decide to take further. |
|
|
MantisBT: master b828c85e 2007-02-20 00:24 Details Diff |
Fixed 0006830: custom_function_override_issue_delete_notify and custom_function_override_issue_update_notify are not being triggered. git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@4275 <a class="text" href="/?p=mantisbt.git;a=object;h=f5dc347c">f5dc347c</a>-c33d-0410-90a0-b07cc1902cb9 |
Affected Issues 0006830 |
|
| mod - bug_delete.php | Diff File | ||
| mod - core/bug_api.php | Diff File | ||
| mod - bug_actiongroup.php | Diff File | ||