diff options
author | mkanat%bugzilla.org <> | 2007-07-07 09:40:40 +0200 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2007-07-07 09:40:40 +0200 |
commit | 92c064fb79e9b1f7236ac82e1ed9724c65b95b5e (patch) | |
tree | 77087ea13b46cc8f08f9d0183567216dd0ec749b /Bugzilla | |
parent | 96b80ae8d12c242dc7129f79e01e5416a9f43c18 (diff) | |
download | bugzilla-92c064fb79e9b1f7236ac82e1ed9724c65b95b5e.tar.gz bugzilla-92c064fb79e9b1f7236ac82e1ed9724c65b95b5e.tar.xz |
Bug 385379: Move dependency DB updating from process_bug into Bugzilla::Bug
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=LpSolit
Diffstat (limited to 'Bugzilla')
-rwxr-xr-x | Bugzilla/Bug.pm | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 10c595d94..1f4ac606f 100755 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -506,6 +506,58 @@ sub update_cc { } # XXX Temporary hack until all of process_bug uses update() +sub update_dependencies { + # We need to send mail for dependson/blocked bugs if the dependencies + # change or the status or resolution change. This var keeps track of that. + my $check_dep_bugs = 0; + + my $self = shift; + + my $dbh = Bugzilla->dbh; + my $delta_ts = shift || $dbh->selectrow_array("SELECT NOW()"); + + my $old_bug = $self->new($self->id); + + my %changes; + foreach my $pair ([qw(dependson blocked)], [qw(blocked dependson)]) { + my ($type, $other) = @$pair; + my $old = $old_bug->$type; + my $new = $self->$type; + + my ($removed, $added) = diff_arrays($old, $new); + foreach my $removed_id (@$removed) { + $dbh->do("DELETE FROM dependencies WHERE $type = ? AND $other = ?", + undef, $removed_id, $self->id); + + # Add an activity entry for the other bug. + LogActivityEntry($removed_id, $other, $self->id, '', + Bugzilla->user->id, $delta_ts); + # Update delta_ts on the other bug so that we trigger mid-airs. + $dbh->do('UPDATE bugs SET delta_ts = ? WHERE bug_id = ?', + undef, $delta_ts, $removed_id); + } + foreach my $added_id (@$added) { + $dbh->do("INSERT INTO dependencies ($type, $other) VALUES (?,?)", + undef, $added_id, $self->id); + + # Add an activity entry for the other bug. + LogActivityEntry($added_id, $other, '', $self->id, + Bugzilla->user->id, $delta_ts); + # Update delta_ts on the other bug so that we trigger mid-airs. + $dbh->do('UPDATE bugs SET delta_ts = ? WHERE bug_id = ?', + undef, $delta_ts, $added_id); + } + + LogActivityEntry($self->id, $type, join(', ', @$removed), + join(', ', @$added), Bugzilla->user->id, $delta_ts); + + $changes{$type} = [$removed, $added]; + } + + return \%changes; +} + +# XXX Temporary hack until all of process_bug uses update() sub update_keywords { my $self = shift; @@ -1096,6 +1148,16 @@ sub fields { # "Set" Methods # ################# +sub set_dependencies { + my ($self, $dependson, $blocked) = @_; + ($dependson, $blocked) = $self->_check_dependencies($dependson, $blocked); + # These may already be detainted, but all setters are supposed to + # detaint their input if they've run a validator (just as though + # we had used Bugzilla::Object::set), so we do that here. + detaint_natural($_) foreach (@$dependson, @$blocked); + $self->{'dependson'} = $dependson; + $self->{'blocked'} = $blocked; +} sub _set_everconfirmed { $_[0]->set('everconfirmed', $_[1]); } sub set_resolution { $_[0]->set('resolution', $_[1]); } sub set_status { |