View Issue Details

IDProjectCategoryView StatusLast Update
0005969mantisbtbugtrackerpublic2005-09-11 08:13
Reporterhgaland Assigned Tothraxisp  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version1.0.0a3 
Fixed in Version1.0.0rc2 
Summary0005969: Incorrect recipients for notifications
Description

Let say:;
1) You have, for a project, different email notifications than for the global configuration.
2) The ALL_PROJETS is the current one in the uper right combo box.
3) You change the status to send a notification.

Result: the notification are not sent according to the bug project's rules, but the default rules.

TagsNo tags attached.
Attached Files
email_api.zip (10,561 bytes)
Patch.txt (3,203 bytes)   
--- email_api.php	1.0.0rc1
+++ email_api.php	2005-07-25 17:40:54.455671200 +0200
@@ -154,9 +154,9 @@
 	# For example, you can get the value associated with notifying "admin"
 	# on action "new", i.e. notify administrators on new bugs which can be
 	# ON or OFF.
-	function email_notify_flag( $action, $flag ) {
-		$t_notify_flags = config_get( 'notify_flags' );
-		$t_default_notify_flags = config_get( 'default_notify_flags' );
+	function email_notify_flag( $action, $flag, $p_project = null  ) {
+		$t_notify_flags = config_get( 'notify_flags', null, null, $p_project );
+		$t_default_notify_flags = config_get( 'default_notify_flags', null, null, $p_project );
 		if ( isset ( $t_notify_flags[$action][$flag] ) ) {
 			return $t_notify_flags[$action][$flag];
 		} elseif ( isset ( $t_default_notify_flags[$flag] ) ) {
@@ -174,25 +174,25 @@
 
 		$t_recipients = array();
 
+		$t_project_id = bug_get_field( $p_bug_id, 'project_id' );
+
 		# add Reporter
-		if ( ON == email_notify_flag( $p_notify_type, 'reporter' ) ) {
+		if ( ON == email_notify_flag( $p_notify_type, 'reporter', $t_project_id ) ) {
 			$t_reporter_id = bug_get_field( $p_bug_id, 'reporter_id' );
 			$t_recipients[$t_reporter_id] = true;
 			log_event( LOG_EMAIL_RECIPIENT, "bug= $p_bug_id, add reporter=$t_reporter_id" );
 		}
 
 		# add Handler
-		if ( ON == email_notify_flag( $p_notify_type, 'handler' )) {
+		if ( ON == email_notify_flag( $p_notify_type, 'handler', $t_project_id )) {
 			$t_handler_id = bug_get_field( $p_bug_id, 'handler_id' );
 			$t_recipients[$t_handler_id] = true;
 			log_event( LOG_EMAIL_RECIPIENT, "bug= $p_bug_id, add handler=$t_handler_id" );
 		}
 
-		$t_project_id = bug_get_field( $p_bug_id, 'project_id' );
-
 		# add users monitoring the bug
 		$t_bug_monitor_table = config_get( 'mantis_bug_monitor_table' );
-		if ( ON == email_notify_flag( $p_notify_type, 'monitor' ) ) {
+		if ( ON == email_notify_flag( $p_notify_type, 'monitor', $t_project_id ) ) {
 			$query = "SELECT DISTINCT user_id
 					  FROM $t_bug_monitor_table
 					  WHERE bug_id=$c_bug_id";
@@ -213,7 +213,7 @@
 		$t_bug_date = bug_get_field( $p_bug_id, 'last_updated' );
 
 		$t_bugnote_table = config_get( 'mantis_bugnote_table' );
-		if ( ON == email_notify_flag( $p_notify_type, 'bugnotes' ) ) {
+		if ( ON == email_notify_flag( $p_notify_type, 'bugnotes', $t_project_id ) ) {
 			$query = "SELECT DISTINCT reporter_id
 					  FROM $t_bugnote_table
 					  WHERE bug_id = $c_bug_id";
@@ -229,8 +229,8 @@
 
 		# add project users who meet the thresholds
 		$t_bug_is_private = bug_get_field( $p_bug_id, 'view_state' ) == VS_PRIVATE;
-		$t_threshold_min = email_notify_flag( $p_notify_type, 'threshold_min' );
-		$t_threshold_max = email_notify_flag( $p_notify_type, 'threshold_max' );
+		$t_threshold_min = email_notify_flag( $p_notify_type, 'threshold_min', $t_project_id );
+		$t_threshold_max = email_notify_flag( $p_notify_type, 'threshold_max', $t_project_id );
 		$t_threshold_users = project_get_all_user_rows( $t_project_id, $t_threshold_min );
 		foreach( $t_threshold_users as $t_user ) {
 			if ( $t_user['access_level'] <= $t_threshold_max ) {
Patch.txt (3,203 bytes)   

Relationships

related to 0005432 closedthraxisp Viewing a bug should change the "current project" 

Activities

thraxisp

thraxisp

2005-07-22 11:41

reporter   ~0010921

I think that this is related to 0005432. The wrong default project was being picked up. This should be fixed now in CVS.

Could you retest it?

hgaland

hgaland

2005-07-25 08:51

reporter   ~0010942

I imported all the modifications from CVS.

The bug persists. The notifications are sent according to the rules of the selected project and not the rules set for the project of the bug.

Sorry

hgaland

hgaland

2005-07-25 11:49

reporter   ~0010948

I Finaly found the bug....

Solution is in email_api.php

The function email_notify_flag( $action, $flag ) should allow a third parameter for project_id (default == null)

Callers in function email_collect_recipients should call the function with the third parameter

I Attached the modified email_api.php file with a patch.txt file.

You should be able to close the case when imported into CVS.

Best regards

thraxisp

thraxisp

2005-07-25 12:44

reporter   ~0010949

Fixed email arising from new bugnotes and a number of other places where the wrong project might be used when the bug's project doesn't match the default.

A more global approact to making the change was used rather than the contributed patch as it covers all reverences to configuration variables, not just the email.

bug_assign_reporter.php -> 1.4
bug_delete.php -> 1.40
bug_file_add.php -> 1.48
bug_file_delete.php -> 1.30
bug_relationship_add.php -> 1.6
bug_relationship_delete.php-> 1.10
bug_relationship_graph.php -> 1.4
bug_reminder.php -> 1.19
bug_reminder_page.php -> 1.22
bug_set_sponsorship.php -> 1.5
bugnote_add.php -> 1.46
bugnote_delete.php -> 1.39
bugnote_edit_page.php -> 1.49
bugnote_set_view_state.php -> 1.27

hgaland

hgaland

2005-07-26 05:27

reporter   ~0010959

I Applied the corrections, ad still a problem.

I afford in your comment, your correction is more accurate... but you forgot the bug_update.php

$t_bug_data = bug_get( $f_bug_id, true );
$t_old_bug_status = $t_bug_data->status;
  • if( $t_bug_data->project_id != helper_get_current_project() ) {
  • in case the current project is not the same project of the bug we are viewing...

  • ... override the current project. This to avoid problems with categories and handlers lists etc.

  • $g_project_override = $t_bug_data->project_id;
  • }
  • $t_bug_data->reporter_id = gpc_get_int( 'reporter_id', $t_bug_data->reporter_id );
    $t_bug_data->handler_id = gpc_get_int( 'handler_id', $t_bug_data->handler_id );
    $t_bug_data->duplicate_id = gpc_get_int( 'duplicate_id', $t_bug_data->duplicate_id );

thraxisp

thraxisp

2005-07-26 07:05

reporter   ~0010962

Added bug_update.php

bug_update.php -> 1.87