perl - Bugzilla Extension: Modifying "Assigned To" field using set_assigned_to in bug_end_update -


i trying modify assigned field on bug (to reporter) when status set resolved. current code looks this:

sub bug_end_of_update {     ($self, $args) = @_;       $bug = $args->{ 'bug' };     $changes = $args->{ 'changes' };     # check if status has changed     if ( $changes->{ 'bug_status' } )     {         ($old_status, $new_status) = @{ $changes->{ 'bug_status' } };         # check if bug status has been set resolved         if ( $new_status eq "resolved" )         {             # change assignee original reporter of bug.             $bug->set_assigned_to( <reporter obj> );              # add changes tracking             $changes->{ 'assigned_to' } = [ <assigned obj>, <reporter obj> ];         }     } } 

i looking 2 things:
1) in bug_end_of_update how reporter user object , assigned user object?
2) changes array looking user objects or login info?

thanks!

this work:

sub bug_end_of_update {     ($self, $args) = @_;      ($bug, $old_bug, $timestamp, $changes) = @$args{qw(bug old_bug timestamp changes)};      if ($changes->{bug_status}[1] eq 'resolved') {      # status has been changed resolved         $bug->set_assigned_to($bug->reporter->login);   # re-assign reporter         $bug->update();     } } 

however, updates bug twice (since bug_end_of_update called once database has been updated).

a better solution is:

sub object_end_of_set_all {     ($self, $args) = @_;      $object = $args->{'object'};      if ($object->isa('bugzilla::bug')) {         if ($object->{'bug_status'} eq 'resolved') {            # bug has been resolved             $object->{'assigned_to'} = $object->{'reporter_id'};    # re-assign reporter         }     } } 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -