Commit b30573c8 authored by mkanat%bugzilla.org's avatar mkanat%bugzilla.org

Bug 412836: Clean up process_bug.cgi now that we have Bugzilla::Bug->update

Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=LpSolit
parent e4666b62
...@@ -494,11 +494,30 @@ sub update { ...@@ -494,11 +494,30 @@ sub update {
# XXX This is just a temporary hack until all updating happens # XXX This is just a temporary hack until all updating happens
# inside this function. # inside this function.
my $delta_ts = shift || $dbh->selectrow_array("SELECT NOW()"); my $delta_ts = shift || $dbh->selectrow_array("SELECT NOW()");
$self->{delta_ts} = $delta_ts;
my $old_bug = $self->new($self->id); my $old_bug = $self->new($self->id);
my $changes = $self->SUPER::update(@_); my $changes = $self->SUPER::update(@_);
# Certain items in $changes have to be fixed so that they hold
# a name instead of an ID.
foreach my $field (qw(product_id component_id)) {
my $change = delete $changes->{$field};
if ($change) {
my $new_field = $field;
$new_field =~ s/_id$//;
$changes->{$new_field} =
[$self->{"_old_${new_field}_name"}, $self->$new_field];
}
}
foreach my $field (qw(qa_contact assigned_to)) {
if ($changes->{$field}) {
my ($from, $to) = @{ $changes->{$field} };
$from = $old_bug->$field->login if $from;
$to = $self->$field->login if $to;
$changes->{$field} = [$from, $to];
}
}
my %old_groups = map {$_->id => $_} @{$old_bug->groups_in}; my %old_groups = map {$_->id => $_} @{$old_bug->groups_in};
my %new_groups = map {$_->id => $_} @{$self->groups_in}; my %new_groups = map {$_->id => $_} @{$self->groups_in};
my ($removed_gr, $added_gr) = diff_arrays([keys %old_groups], my ($removed_gr, $added_gr) = diff_arrays([keys %old_groups],
...@@ -565,16 +584,6 @@ sub update { ...@@ -565,16 +584,6 @@ sub update {
my $change = $changes->{$field}; my $change = $changes->{$field};
my $from = defined $change->[0] ? $change->[0] : ''; my $from = defined $change->[0] ? $change->[0] : '';
my $to = defined $change->[1] ? $change->[1] : ''; my $to = defined $change->[1] ? $change->[1] : '';
# Certain fields have their name stored in bugs_activity, not their id.
if ( grep($_ eq $field, qw(product_id component_id)) ) {
$field =~ s/_id$//;
$from = $self->{"_old_${field}_name"};
$to = $self->$field;
}
if (grep ($_ eq $field, qw(qa_contact assigned_to))) {
$from = $old_bug->$field->login if $from;
$to = $self->$field->login if $to;
}
LogActivityEntry($self->id, $field, $from, $to, Bugzilla->user->id, LogActivityEntry($self->id, $field, $from, $to, Bugzilla->user->id,
$delta_ts); $delta_ts);
} }
...@@ -598,6 +607,7 @@ sub update { ...@@ -598,6 +607,7 @@ sub update {
if (scalar(keys %$changes) || $self->{added_comments}) { if (scalar(keys %$changes) || $self->{added_comments}) {
$dbh->do('UPDATE bugs SET delta_ts = ? WHERE bug_id = ?', $dbh->do('UPDATE bugs SET delta_ts = ? WHERE bug_id = ?',
undef, ($delta_ts, $self->id)); undef, ($delta_ts, $self->id));
$self->{delta_ts} = $delta_ts;
} }
return $changes; return $changes;
...@@ -745,6 +755,7 @@ sub update_keywords { ...@@ -745,6 +755,7 @@ sub update_keywords {
$dbh->do('UPDATE bugs SET delta_ts = ? WHERE bug_id = ?', $dbh->do('UPDATE bugs SET delta_ts = ? WHERE bug_id = ?',
undef, ($delta_ts, $self->id)); undef, ($delta_ts, $self->id));
$self->{delta_ts} = $delta_ts;
} }
return [$removed_keywords, $added_keywords]; return [$removed_keywords, $added_keywords];
......
...@@ -1151,9 +1151,6 @@ sub match_field { ...@@ -1151,9 +1151,6 @@ sub match_field {
# prepare default form values # prepare default form values
# What does a "--do_not_change--" field look like (if any)?
my $dontchange = $cgi->param('dontchange');
# Fields can be regular expressions matching multiple form fields # Fields can be regular expressions matching multiple form fields
# (f.e. "requestee-(\d+)"), so expand each non-literal field # (f.e. "requestee-(\d+)"), so expand each non-literal field
# into the list of form fields it matches. # into the list of form fields it matches.
...@@ -1212,9 +1209,6 @@ sub match_field { ...@@ -1212,9 +1209,6 @@ sub match_field {
next if !defined $cgi->param($field); next if !defined $cgi->param($field);
# Skip it if this is a --do_not_change-- field
next if $dontchange && $dontchange eq $cgi->param($field);
# We need to move the query to $raw_field, where it will be split up, # We need to move the query to $raw_field, where it will be split up,
# modified by the search, and put back into the CGI environment # modified by the search, and put back into the CGI environment
# incrementally. # incrementally.
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
# entered a comment along with their change) or a number less than that # entered a comment along with their change) or a number less than that
# (if they didn't), in which case no comments are displayed. # (if they didn't), in which case no comments are displayed.
# comments: array; all the comments on the bug. # comments: array; all the comments on the bug.
# bug_id: number; the ID of the bug being changed. # bug: Bugzilla::Bug; the bug being changed.
#%] #%]
[%# The global Bugzilla->cgi object is used to obtain form variable values. %] [%# The global Bugzilla->cgi object is used to obtain form variable values. %]
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
<p> <p>
Someone else has made changes to Someone else has made changes to
[%+ "$terms.bug $bug_id" FILTER bug_link(bug_id) FILTER none %] [%+ "$terms.bug $bug.id" FILTER bug_link(bug.id) FILTER none %]
at the same time you were trying to. at the same time you were trying to.
The changes made were: The changes made were:
</p> </p>
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
<p> <p>
Added the comment(s): Added the comment(s):
<blockquote> <blockquote>
[% PROCESS "bug/comments.html.tmpl" bug = { 'bug_id' => bug_id } %] [% PROCESS "bug/comments.html.tmpl" %]
</blockquote> </blockquote>
</p> </p>
[% END %] [% END %]
...@@ -77,7 +77,10 @@ You have the following choices: ...@@ -77,7 +77,10 @@ You have the following choices:
<ul> <ul>
<li> <li>
<form method="post" action="process_bug.cgi"> <form method="post" action="process_bug.cgi">
[% PROCESS "global/hidden-fields.html.tmpl" exclude="^Bugzilla_(login|password)$" %] <input type="hidden" name="delta_ts"
value="[% bug.delta_ts FILTER html %]">
[% PROCESS "global/hidden-fields.html.tmpl"
exclude="^Bugzilla_login|Bugzilla_password|delta_ts$" %]
<input type="submit" id="process" value="Submit my changes anyway"> <input type="submit" id="process" value="Submit my changes anyway">
This will cause all of the above changes to be overwritten This will cause all of the above changes to be overwritten
[% ", except for the added comment(s)" IF comments.size > start_at %]. [% ", except for the added comment(s)" IF comments.size > start_at %].
...@@ -85,7 +88,7 @@ You have the following choices: ...@@ -85,7 +88,7 @@ You have the following choices:
</li> </li>
<li> <li>
Throw away my changes, and Throw away my changes, and
[%+ "revisit $terms.bug $bug_id" FILTER bug_link(bug_id) FILTER none %] [%+ "revisit $terms.bug $bug.id" FILTER bug_link(bug.id) FILTER none %]
</li> </li>
</ul> </ul>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment