]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 556736: Make the bug_end_of_update hook also send $old_bug to the hook
authorMax Kanat-Alexander <mkanat@bugzilla.org>
Fri, 2 Apr 2010 11:51:17 +0000 (04:51 -0700)
committerMax Kanat-Alexander <mkanat@bugzilla.org>
Fri, 2 Apr 2010 11:51:17 +0000 (04:51 -0700)
r=mkanat, a=mkanat (module owner)

Bugzilla/Bug.pm
Bugzilla/Hook.pm
extensions/Example/Extension.pm

index 95d1c281125918362149c1d14d906ad15c52cd58..5696880fa196f510f22e912c67be8fa97f26114f 100644 (file)
@@ -867,10 +867,9 @@ sub update {
         $changes->{'dup_id'} = [$old_dup || undef, $cur_dup || undef];
     }
 
-    Bugzilla::Hook::process('bug_end_of_update', { bug       => $self,
-                                                   timestamp => $delta_ts,
-                                                   changes   => $changes,
-                                                 });
+    Bugzilla::Hook::process('bug_end_of_update', 
+        { bug => $self, timestamp => $delta_ts, changes => $changes,
+          old_bug => $old_bug });
 
     # If any change occurred, refresh the timestamp of the bug.
     if (scalar(keys %$changes) || $self->{added_comments}) {
index a3a1752238f8f0045efbfdd364e48c7cb2ab63df..9917c68e843ec2432e2264cc565342ccf6cc25d7 100644 (file)
@@ -237,13 +237,22 @@ Params:
 
 =over
 
-=item C<bug> - The changed bug object, with all fields set to their updated
-values.
+=item C<bug> 
 
-=item C<timestamp> - The timestamp used for all updates in this transaction.
+The changed bug object, with all fields set to their updated values.
 
-=item C<changes> - The hash of changed fields. 
-C<$changes-E<gt>{field} = [old, new]>
+=item C<old_bug>
+
+A bug object pulled from the database before the fields were set to
+their updated values (so it has the old values available for each field).
+
+=item C<timestamp> 
+
+The timestamp used for all updates in this transaction.
+
+=item C<changes> 
+
+The hash of changed fields. C<< $changes->{field} = [old, new] >>
 
 =back
 
index 9de0a65bf44e43c6f3d8f831ead8097029560ecd..0c795f80895a6c054b03425bce4d5031d4e242ad 100644 (file)
@@ -114,13 +114,16 @@ sub bug_end_of_update {
     
     # This code doesn't actually *do* anything, it's just here to show you
     # how to use this hook.
-    my ($bug, $timestamp, $changes) = @$args{qw(bug timestamp changes)};
+    my ($bug, $old_bug, $timestamp, $changes) = 
+        @$args{qw(bug old_bug timestamp changes)};
     
     foreach my $field (keys %$changes) {
         my $used_to_be = $changes->{$field}->[0];
         my $now_it_is  = $changes->{$field}->[1];
     }
-    
+
+    my $old_summary = $old_bug->short_desc;
+
     my $status_message;
     if (my $status_change = $changes->{'bug_status'}) {
         my $old_status = new Bugzilla::Status({ name => $status_change->[0] });