[bugzilla-gnome-org-upstream/4.4: 12/19] Bug 1111043: Bug.add_comment returns the wrong comment ID r/a=dkl



commit 4dba1879f9f70c334ee6a1ba6a992d4aea9232fd
Author: Frédéric Buclin <LpSolit gmail com>
Date:   Wed Dec 17 20:42:10 2014 +0100

    Bug 1111043: Bug.add_comment returns the wrong comment ID
    r/a=dkl

 Bugzilla/WebService/Bug.pm |   15 +++------------
 1 files changed, 3 insertions(+), 12 deletions(-)
---
diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm
index 670d234..7dedc5b 100644
--- a/Bugzilla/WebService/Bug.pm
+++ b/Bugzilla/WebService/Bug.pm
@@ -707,19 +707,10 @@ sub add_comment {
     # Append comment
     $bug->add_comment($comment, { isprivate => $params->{is_private},
                                   work_time => $params->{work_time} });
-    
-    # Capture the call to bug->update (which creates the new comment) in 
-    # a transaction so we're sure to get the correct comment_id.
-    
-    my $dbh = Bugzilla->dbh;
-    $dbh->bz_start_transaction();
-    
     $bug->update();
-    
-    my $new_comment_id = $dbh->bz_last_key('longdescs', 'comment_id');
-    
-    $dbh->bz_commit_transaction();
-    
+
+    my $new_comment_id = $bug->{added_comments}[0]->id;
+
     # Send mail.
     Bugzilla::BugMail::Send($bug->bug_id, { changer => $user });
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]