From: mkanat%bugzilla.org <> Date: Wed, 20 Aug 2008 03:14:02 +0000 (+0000) Subject: Bug 449306: Add a hook after a bug gets saved, and after flags get updated. X-Git-Tag: bugzilla-3.2rc2~87 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=480b28235afe19e6211ff2e13b15e1798afa25d7;p=thirdparty%2Fbugzilla.git Bug 449306: Add a hook after a bug gets saved, and after flags get updated. Patch By Jesse Clark r=mkanat, a=mkanat --- diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 1fb3887f49..0b635012fc 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -35,6 +35,7 @@ use Bugzilla::Constants; use Bugzilla::Field; use Bugzilla::Flag; use Bugzilla::FlagType; +use Bugzilla::Hook; use Bugzilla::Keyword; use Bugzilla::User; use Bugzilla::Util; @@ -692,6 +693,11 @@ 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, + }); + # If any change occurred, refresh the timestamp of the bug. if (scalar(keys %$changes) || $self->{added_comments}) { $dbh->do('UPDATE bugs SET delta_ts = ? WHERE bug_id = ?', diff --git a/Bugzilla/Flag.pm b/Bugzilla/Flag.pm index 6266b0c0cc..73266ce9f2 100644 --- a/Bugzilla/Flag.pm +++ b/Bugzilla/Flag.pm @@ -54,6 +54,7 @@ whose names start with _ or a re specifically noted as being private. =cut use Bugzilla::FlagType; +use Bugzilla::Hook; use Bugzilla::User; use Bugzilla::Util; use Bugzilla::Error; @@ -612,6 +613,12 @@ sub process { my @new_summaries = $class->snapshot($bug_id, $attach_id); update_activity($bug_id, $attach_id, $timestamp, \@old_summaries, \@new_summaries); + + Bugzilla::Hook::process('flag-end_of_update', { bug => $bug, + timestamp => $timestamp, + old_flags => \@old_summaries, + new_flags => \@new_summaries, + }); } sub update_activity { diff --git a/Bugzilla/Hook.pm b/Bugzilla/Hook.pm index fb63d3b224..2436ac1ad3 100644 --- a/Bugzilla/Hook.pm +++ b/Bugzilla/Hook.pm @@ -170,6 +170,25 @@ This describes what hooks exist in Bugzilla currently. They are mostly in alphabetical order, but some related hooks are near each other instead of being alphabetical. +=head2 bug-end_of_update + +This happens at the end of L, after all other changes are +made to the database. This generally occurs inside a database transaction. + +Params: + +=over + +=item C - The changed bug object, with all fields set to their updated +values. + +=item C - The timestamp used for all updates in this transaction. + +=item C - The hash of changed fields. +C<$changes-E{field} = [old, new]> + +=back + =head2 buglist-columns This happens in buglist.cgi after the standard columns have been defined and @@ -226,6 +245,32 @@ Params: =back +=head2 flag-end_of_update + +This happens at the end of L, after all other changes +are made to the database and after emails are sent. It gives you a before/after +snapshot of flags so you can react to specific flag changes. +This generally occurs inside a database transaction. + +Note that the interface to this hook is B and it may change in the +future. + +Params: + +=over + +=item C - The changed bug object. + +=item C - The timestamp used for all updates in this transaction. + +=item C - The snapshot of flag summaries from before the change. + +=item C - The snapshot of flag summaries after the change. Call +C to get the list of +changed flags, and search for a specific condition like C. + +=back + =head2 install-requirements Because of the way Bugzilla installation works, there can't be a normal