summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kanat-Alexander <mkanat@bugzilla.org>2010-04-02 13:50:34 +0200
committerMax Kanat-Alexander <mkanat@bugzilla.org>2010-04-02 13:50:34 +0200
commit07f947c99e162dc991f368cd5ff9065824c4ec86 (patch)
treed00294be29107380d60f0565438d84f7769c6d5b
parent2a444f9d50535445a84367a9833bd87a07752d0a (diff)
downloadbugzilla-07f947c99e162dc991f368cd5ff9065824c4ec86.tar.gz
bugzilla-07f947c99e162dc991f368cd5ff9065824c4ec86.tar.xz
Bug 556736: Make the bug_end_of_update hook also send $old_bug to the hook
r=mkanat, a=mkanat (module owner)
-rw-r--r--Bugzilla/Bug.pm7
-rw-r--r--Bugzilla/Hook.pm19
-rw-r--r--extensions/Example/Extension.pm7
3 files changed, 22 insertions, 11 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index da5cf9285..0d6a4be17 100644
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -865,10 +865,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}) {
diff --git a/Bugzilla/Hook.pm b/Bugzilla/Hook.pm
index 556fda894..b8d763d20 100644
--- a/Bugzilla/Hook.pm
+++ b/Bugzilla/Hook.pm
@@ -239,13 +239,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
diff --git a/extensions/Example/Extension.pm b/extensions/Example/Extension.pm
index 52ac66231..835d36f80 100644
--- a/extensions/Example/Extension.pm
+++ b/extensions/Example/Extension.pm
@@ -119,13 +119,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] });