View Issue Details

IDProjectCategoryView StatusLast Update
0014897mantisbtplug-inspublic2016-07-11 15:45
Reporterrct Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
Status acknowledgedResolutionopen 
Product Version1.2.11 
Summary0014897: Plugins events features request
Description

Hello,

I'm trying to update my plugin (http://www.mantisbt.org/forums/viewtopic.php?f=4&t=20021) to check for version, target version and fixed in version.
I would like it to work like custom fields (required on report, required on update, required on resolved and required on closed).
But I have problems to do so : :(

Explanations :
My plugin subscribe to those events : EVENT_REPORT_BUG_DATA, EVENT_UPDATE_BUG but it looks like it does not do the full job :

  • Group actions don't trigger those events and the EVENT_BUG_ACTION is triggered after the bug is saved into the database (according to documentation it's ok but an event that will be triggered before would be nice ! )
  • In the "View Issue Details" page when "Change status to" is set to Resolved or Closed the EVENT_UPDATE_BUG event is only triggered AFTER bug is saved into the database

It will be nice if those features will be added in a future release :)

TagsNo tags attached.
Attached Files
patch.diff (9,228 bytes)   
diff --git a/bug_actiongroup.php b/bug_actiongroup.php
index 5c04727..89edd48 100644
--- a/bug_actiongroup.php
+++ b/bug_actiongroup.php
@@ -75,8 +75,12 @@
 			if ( access_can_close_bug( $t_bug ) ) {
 				if( ( $t_status < $t_closed ) &&
 					bug_check_workflow( $t_status, $t_closed ) ) {
-
 					/** @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $f_bug_id, $t_bug_data, $f_bugnote_text ) ); */
+					# Plugin support
+					$t_new_bug_data = event_signal( 'EVENT_UPDATE_BUG', $t_bug, $t_bug_id );
+					if ( !is_null( $t_new_bug_data ) ) {
+						$t_bug = $t_new_bug_data;
+					}
 					bug_close( $t_bug_id, $f_bug_notetext, $f_bug_noteprivate );
 					helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 				} else {
@@ -101,6 +105,11 @@
 			if( access_has_bug_level( config_get( 'move_bug_threshold' ), $t_bug_id ) &&
 			    access_has_project_level( config_get( 'report_bug_threshold', null, null, $f_project_id ), $f_project_id ) ) {
 				/** @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) ); */
+				# Plugin support
+				$t_new_bug_data = event_signal( 'EVENT_UPDATE_BUG', $t_bug, $t_bug_id );
+				if ( !is_null( $t_new_bug_data ) ) {
+					$t_bug = $t_new_bug_data;
+				}
 				bug_move( $t_bug_id, $f_project_id );
 				helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 			} else {
@@ -133,6 +142,11 @@
 				if ( access_has_bug_level( config_get( 'handle_bug_threshold' ), $t_bug_id, $f_assign ) ) {
 					if ( bug_check_workflow( $t_status, $t_assign_status ) ) {
 						/** @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) ); */
+						# Plugin support
+						$t_new_bug_data = event_signal( 'EVENT_UPDATE_BUG', $t_bug, $t_bug_id );
+						if ( !is_null( $t_new_bug_data ) ) {
+							$t_bug = $t_new_bug_data;
+						}
 						bug_assign( $t_bug_id, $f_assign, $f_bug_notetext, $f_bug_noteprivate );
 						helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 					} else {
@@ -153,7 +167,17 @@
 						bug_check_workflow($t_status, $t_resolved_status ) ) {
 					$f_resolution = gpc_get_int( 'resolution' );
 					$f_fixed_in_version = gpc_get_string( 'fixed_in_version', '' );
+					# Plugin support
+					$t_new_bug_data = event_signal( 'EVENT_UPDATE_BUG', $t_bug, $t_bug_id );
+					if ( !is_null( $t_new_bug_data ) ) {
+						$t_bug = $t_new_bug_data;
+					}
 					/** @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) ); */
+					# Plugin support
+					$t_new_bug_data = event_signal( 'EVENT_UPDATE_BUG', $t_bug, $t_bug_id );
+					if ( !is_null( $t_new_bug_data ) ) {
+						$t_bug = $t_new_bug_data;
+					}
 					bug_resolve( $t_bug_id, $f_resolution, null, $f_fixed_in_version, null, null, $f_bug_notetext, $f_bug_noteprivate );
 					helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 				} else {
@@ -168,6 +192,11 @@
 			if ( access_has_bug_level( config_get( 'update_bug_threshold' ), $t_bug_id ) ) {
 				$f_priority = gpc_get_int( 'priority' );
 				/** @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) ); */
+				# Plugin support
+				$t_new_bug_data = event_signal( 'EVENT_UPDATE_BUG', $t_bug, $t_bug_id );
+				if ( !is_null( $t_new_bug_data ) ) {
+					$t_bug = $t_new_bug_data;
+				}
 				bug_set_field( $t_bug_id, 'priority', $f_priority );
 				helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 			} else {
@@ -181,6 +210,11 @@
 			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 ) ) {
 					/** @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) ); */
+					# Plugin support
+					$t_new_bug_data = event_signal( 'EVENT_UPDATE_BUG', $t_bug, $t_bug_id );
+					if ( !is_null( $t_new_bug_data ) ) {
+						$t_bug = $t_new_bug_data;
+					}
 					bug_set_field( $t_bug_id, 'status', $f_status );
 
 					# Add bugnote if supplied
@@ -202,6 +236,11 @@
 			if ( access_has_bug_level( config_get( 'update_bug_threshold' ), $t_bug_id ) ) {
 				if ( category_exists( $f_category_id ) ) {
 					/** @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) ); */
+					# Plugin support
+					$t_new_bug_data = event_signal( 'EVENT_UPDATE_BUG', $t_bug, $t_bug_id );
+					if ( !is_null( $t_new_bug_data ) ) {
+						$t_bug = $t_new_bug_data;
+					}
 					bug_set_field( $t_bug_id, 'category_id', $f_category_id );
 					helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 				} else {
@@ -219,6 +258,11 @@
 			if ( access_has_bug_level( config_get( 'update_bug_threshold' ), $t_bug_id ) ) {
 				if ( $f_fixed_in_version === '' || version_get_id( $f_fixed_in_version, $t_project_id ) !== false ) {
 					/** @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) ); */
+					# Plugin support
+					$t_new_bug_data = event_signal( 'EVENT_UPDATE_BUG', $t_bug, $t_bug_id );
+					if ( !is_null( $t_new_bug_data ) ) {
+						$t_bug = $t_new_bug_data;
+					}
 					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 {
@@ -236,6 +280,11 @@
 			if ( access_has_bug_level( config_get( 'roadmap_update_threshold' ), $t_bug_id ) ) {
 				if ( $f_target_version === '' || version_get_id( $f_target_version, $t_project_id ) !== false ) {
 					/** @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) ); */
+					# Plugin support
+					$t_new_bug_data = event_signal( 'EVENT_UPDATE_BUG', $t_bug, $t_bug_id );
+					if ( !is_null( $t_new_bug_data ) ) {
+						$t_bug = $t_new_bug_data;
+					}
 					bug_set_field( $t_bug_id, 'target_version', $f_target_version );
 					helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 				} else {
@@ -250,6 +299,11 @@
 			if ( access_has_bug_level( config_get( 'change_view_status_threshold' ), $t_bug_id ) ) {
 				$f_view_status = gpc_get_int( 'view_status' );
 				/** @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) ); */
+				# Plugin support
+				$t_new_bug_data = event_signal( 'EVENT_UPDATE_BUG', $t_bug, $t_bug_id );
+				if ( !is_null( $t_new_bug_data ) ) {
+					$t_bug = $t_new_bug_data;
+				}
 				bug_set_field( $t_bug_id, 'view_state', $f_view_status );
 				helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 			} else {
@@ -262,6 +316,11 @@
 				$f_sticky = bug_get_field( $t_bug_id, 'sticky' );
 				// The new value is the inverted old value
 				/** @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) ); */
+				# Plugin support
+				$t_new_bug_data = event_signal( 'EVENT_UPDATE_BUG', $t_bug, $t_bug_id );
+				if ( !is_null( $t_new_bug_data ) ) {
+					$t_bug = $t_new_bug_data;
+				}
 				bug_set_field( $t_bug_id, 'sticky', intval( !$f_sticky ) );
 				helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 			} else {
@@ -275,6 +334,11 @@
 			}
 
 			/** @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) ); */
+			# Plugin support
+			$t_new_bug_data = event_signal( 'EVENT_UPDATE_BUG', $t_bug, $t_bug_id );
+			if ( !is_null( $t_new_bug_data ) ) {
+				$t_bug = $t_new_bug_data;
+			}
 			$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 );
diff --git a/bug_update.php b/bug_update.php
index bfdebb8..911cbdd 100644
--- a/bug_update.php
+++ b/bug_update.php
@@ -166,6 +166,13 @@
 			trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR );
 		}
 	}
+	
+
+	# Plugin support
+	$t_new_bug_data = event_signal( 'EVENT_UPDATE_BUG', $t_bug_data, $f_bug_id );
+	if ( !is_null( $t_new_bug_data ) ) {
+		$t_bug_data = $t_new_bug_data;
+	}
 
 	$t_notify = true;
 	$t_bug_note_set = false;
@@ -213,12 +220,6 @@
 			$t_bug_data->status = bug_get_field( $f_bug_id, 'status' );
 			$t_bug_data->resolution = bug_get_field( $f_bug_id, 'resolution' );
 		}
-	}
-
-	# Plugin support
-	$t_new_bug_data = event_signal( 'EVENT_UPDATE_BUG', $t_bug_data, $f_bug_id );
-	if ( !is_null( $t_new_bug_data ) ) {
-		$t_bug_data = $t_new_bug_data;
 	}
 
 	# Add a bugnote if there is one
patch.diff (9,228 bytes)   

Relationships

has duplicate 0015559 closedatrol EVENT_UPDATE_BUG triggers missing 
related to 0020578 new move some events into core API 

Activities

cas

cas

2013-03-14 04:42

reporter   ~0035864

So is this on the todo list, to ensure that events (like mentioned above)are defined consistently?
One of my plugins is using that event in order to prohibit actions but given how it is configured, the action continues. Took me some time to realize that there was a flaw in thye plugin.
For me it is a bug which needs serious attention because "it prevent to build a reliable plugin" as mentioned in 15559.
The EVENT_UPDATE_BUG should be triggered at the same moment with all 3 options to update the bug.
Since my plugin is relying on this particular event, I will try to achieve this and deliver some patches here.
But I do hope that a consistency check is conducted when new events are added in the future.

rct

rct

2013-04-21 05:22

reporter   ~0036638

I haven't tested but as I can see in the code it seems in the code that Atrol has resolved the bug (see 0015559).

Thanks

dregad

dregad

2013-04-21 12:31

developer   ~0036639

rct, what are you talking about ? 0015559 does not contain any patch, atrol just marked it as duplicate of this. And as far as I can see, there are no new events hooks defined in the code.

You're still welcome to provide a patch for this.

Note for future development - there are additional details in 0015559

rct

rct

2013-04-27 06:00

reporter   ~0036693

Right no code has been modified.
I'll try to do this patch.

rct

rct

2013-05-03 13:28

reporter   ~0036783

I'm not familiar with GIT nor all the pull request and other stuff.
I've spent hours trying to but I can't do more than upload the patch here... Sorry.

rct

rct

2013-05-08 05:13

reporter   ~0036805

I've added a pull request for this : https://github.com/mantisbt/mantisbt/pull/83

dregad

dregad

2013-05-08 08:18

developer   ~0036809

Thanks, I'll review as time allows.

rct

rct

2013-05-08 08:31

reporter   ~0036811

Nice :)

rct

rct

2013-09-02 12:54

reporter   ~0037976

Any news for this?

mneute

mneute

2015-03-02 11:17

reporter   ~0049115

Any news for this ?
This is blocking me.