From a7a89837840c2eda88583018a27f89be678b1dd4 Mon Sep 17 00:00:00 2001
From: Damien Regad <damien.regad@merckgroup.com>
Date: Mon, 6 Aug 2012 12:15:00 +0200
Subject: [PATCH] email_collect_recipients() did not retrieve all users who
 added bugnotes

Fixes #14549 by using db_fetch_array() instead of db_result().

Note: I noticed some strange behavior in the for loop at line 268 in
email_api with the old code: it looks like the value of $i is modified
in the middle of the loop by the call to $p_result->GetArray() in
db_result(), causing the code to skip records.
---
 core/email_api.php |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/core/email_api.php b/core/email_api.php
index 4422898..298f136 100644
--- a/core/email_api.php
+++ b/core/email_api.php
@@ -264,9 +264,8 @@ function email_collect_recipients( $p_bug_id, $p_notify_type, $p_extra_user_ids_
 					  WHERE bug_id = " . db_param();
 		$result = db_query_bound( $query, Array( $c_bug_id ) );
 
-		$count = db_num_rows( $result );
-		for( $i = 0;$i < $count;$i++ ) {
-			$t_user_id = db_result( $result, $i );
+		while( $row = db_fetch_array( $result ) ) {
+			$t_user_id = $row['reporter_id'];
 			$t_recipients[$t_user_id] = true;
 			log_event( LOG_EMAIL_RECIPIENT, sprintf( 'Issue = #%d, add Note Author = @U%d', $p_bug_id, $t_user_id ) );
 		}
-- 
1.7.9.5

