summaryrefslogtreecommitdiffstats
path: root/process_bug.cgi
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2007-07-04 21:56:25 +0200
committermkanat%bugzilla.org <>2007-07-04 21:56:25 +0200
commit09b34ef6593a89e0e9a364fe73a2b1aed80741e7 (patch)
tree99d615c49de8b1428ab443eb4f6f58b8e3512f10 /process_bug.cgi
parentef86c4226f7163a17f611759471f71692319a4af (diff)
downloadbugzilla-09b34ef6593a89e0e9a364fe73a2b1aed80741e7.tar.gz
bugzilla-09b34ef6593a89e0e9a364fe73a2b1aed80741e7.tar.xz
Bug 384664: Make keywords use Bugzilla::Bug in process_bug
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=LpSolit
Diffstat (limited to 'process_bug.cgi')
-rwxr-xr-xprocess_bug.cgi100
1 files changed, 11 insertions, 89 deletions
diff --git a/process_bug.cgi b/process_bug.cgi
index 4b5d0ec54..253de665f 100755
--- a/process_bug.cgi
+++ b/process_bug.cgi
@@ -882,34 +882,18 @@ $requiremilestone = $vars->{requiremilestone};
DuplicateUserConfirm($bug, $duplicate) if $vars->{DuplicateUserConfirm};
_remove_remaining_time() if $vars->{remove_remaining_time};
-my @keywordlist;
-my %keywordseen;
-
+my $any_keyword_changes;
if (defined $cgi->param('keywords')) {
- foreach my $keyword (split(/[\s,]+/, $cgi->param('keywords'))) {
- if ($keyword eq '') {
- next;
- }
- my $keyword_obj = new Bugzilla::Keyword({name => $keyword});
- if (!$keyword_obj) {
- ThrowUserError("unknown_keyword",
- { keyword => $keyword });
- }
- if (!$keywordseen{$keyword_obj->id}) {
- push(@keywordlist, $keyword_obj->id);
- $keywordseen{$keyword_obj->id} = 1;
- }
+ foreach my $b (@bug_objects) {
+ my $return =
+ $b->modify_keywords(scalar $cgi->param('keywords'),
+ scalar $cgi->param('keywordaction'));
+ $any_keyword_changes ||= $return;
}
}
-my $keywordaction = $cgi->param('keywordaction') || "makeexact";
-if (!grep($keywordaction eq $_, qw(add delete makeexact))) {
- $keywordaction = "makeexact";
-}
-
if ($::comma eq ""
- && (!Bugzilla::Keyword::keyword_count()
- || (0 == @keywordlist && $keywordaction ne "makeexact"))
+ && !$any_keyword_changes
&& defined $cgi->param('masscc') && ! $cgi->param('masscc')
) {
if (!defined $cgi->param('comment') || $cgi->param('comment') =~ /^\s*$/) {
@@ -1184,25 +1168,6 @@ foreach my $id (@idlist) {
}
}
- # When editing multiple bugs, users can specify a list of keywords to delete
- # from bugs. If the list matches the current set of keywords on those bugs,
- # Bug::check_can_change_field will fail to check permissions because it thinks
- # the list hasn't changed. To fix that, we have to call Bug::check_can_change_field
- # again with old!=new if the keyword action is "delete" and old=new.
- if ($keywordaction eq "delete"
- && defined $cgi->param('keywords')
- && length(@keywordlist) > 0
- && $cgi->param('keywords') eq $oldhash{keywords}
- && !$old_bug_obj->check_can_change_field("keywords", "old is not", "equal to new",
- \$PrivilegesRequired))
- {
- $vars->{'oldvalue'} = $oldhash{keywords};
- $vars->{'newvalue'} = "no keywords";
- $vars->{'field'} = "keywords";
- $vars->{'privs'} = $PrivilegesRequired;
- ThrowUserError("illegal_change", $vars);
- }
-
$oldhash{'product'} = $old_bug_obj->product;
if (!Bugzilla->user->can_edit_product($oldhash{'product_id'})) {
ThrowUserError("product_edit_denied",
@@ -1287,49 +1252,8 @@ foreach my $id (@idlist) {
$bug_changed = 1;
}
- if (Bugzilla::Keyword::keyword_count()
- && defined $cgi->param('keywords'))
- {
- # There are three kinds of "keywordsaction": makeexact, add, delete.
- # For makeexact, we delete everything, and then add our things.
- # For add, we delete things we're adding (to make sure we don't
- # end up having them twice), and then we add them.
- # For delete, we just delete things on the list.
- my $changed = 0;
- if ($keywordaction eq "makeexact") {
- $dbh->do(q{DELETE FROM keywords WHERE bug_id = ?},
- undef, $id);
- $changed = 1;
- }
- my $sth_delete = $dbh->prepare(q{DELETE FROM keywords
- WHERE bug_id = ?
- AND keywordid = ?});
- my $sth_insert =
- $dbh->prepare(q{INSERT INTO keywords (bug_id, keywordid)
- VALUES (?, ?)});
- foreach my $keyword (@keywordlist) {
- if ($keywordaction ne "makeexact") {
- $sth_delete->execute($id, $keyword);
- $changed = 1;
- }
- if ($keywordaction ne "delete") {
- $sth_insert->execute($id, $keyword);
- $changed = 1;
- }
- }
- if ($changed) {
- my $list = $dbh->selectcol_arrayref(
- q{SELECT keyworddefs.name
- FROM keyworddefs
- INNER JOIN keywords
- ON keyworddefs.id = keywords.keywordid
- WHERE keywords.bug_id = ?
- ORDER BY keyworddefs.name},
- undef, $id);
- $dbh->do("UPDATE bugs SET keywords = ? WHERE bug_id = ?",
- undef, join(', ', @$list), $id);
- }
- }
+ $bug_objects{$id}->update_keywords($timestamp);
+
$query .= " WHERE bug_id = ?";
push(@bug_values, $id);
@@ -1546,10 +1470,8 @@ foreach my $id (@idlist) {
$origQaContact = $old;
}
- # If this is the keyword field, only record the changes, not everything.
- if ($col eq 'keywords') {
- ($old, $new) = diff_strings($old, $new);
- }
+ # update_keywords does this for us already.
+ next if ($col eq 'keywords');
if ($col eq 'product') {
# If some votes have been removed, RemoveVotes() returns