diff options
author | mkanat%bugzilla.org <> | 2006-09-10 11:24:21 +0200 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2006-09-10 11:24:21 +0200 |
commit | e0c777f375e063fbe16dbb18a995bf865475ca43 (patch) | |
tree | 0ca0abb2966effa8ca7e91ff8aa834c879f535ec /Bugzilla | |
parent | bb61c992c9c2ff6c9d51ac9fcde5165bf6be7e21 (diff) | |
download | bugzilla-e0c777f375e063fbe16dbb18a995bf865475ca43.tar.gz bugzilla-e0c777f375e063fbe16dbb18a995bf865475ca43.tar.xz |
Bug 351345: Move keyword insertion out of post_bug.cgi and into Bugzilla::Bug
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=justdave
Diffstat (limited to 'Bugzilla')
-rwxr-xr-x | Bugzilla/Bug.pm | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 0dfc91668..4f1939423 100755 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -118,6 +118,7 @@ sub VALIDATORS { cc => \&_check_cc, deadline => \&_check_deadline, estimated_time => \&_check_estimated_time, + keywords => \&_check_keywords, op_sys => \&_check_op_sys, priority => \&_check_priority, product => \&_check_product, @@ -249,6 +250,11 @@ sub create { my $groups = $params->{groups}; delete $params->{groups}; + # Set up the keyword cache for bug creation. + my $keywords = $params->{keywords}; + $params->{keywords} = join(', ', sort {lc($a) cmp lc($b)} + map($_->name, @$keywords)); + my $bug = $class->insert_create_data($params); # Add the group restrictions @@ -264,6 +270,13 @@ sub create { $sth_cc->execute($bug->bug_id, $user_id); } + # Add in keywords + my $sth_keyword = $dbh->prepare( + 'INSERT INTO keywords (bug_id, keywordid) VALUES (?, ?)'); + foreach my $keyword_id (map($_->id, @$keywords)) { + $sth_keyword->execute($bug->bug_id, $keyword_id); + } + return $bug; } @@ -585,14 +598,14 @@ sub _check_keywords { $keyword_string = trim($keyword_string); return [] if (!$keyword_string || !Bugzilla->user->in_group('editbugs')); - my %keyword_ids; + my %keywords; foreach my $keyword (split(/[\s,]+/, $keyword_string)) { next unless $keyword; my $obj = new Bugzilla::Keyword({ name => $keyword }); ThrowUserError("unknown_keyword", { keyword => $keyword }) if !$obj; - $keyword_ids{$obj->id} = 1; + $keywords{$obj->id} = $obj; } - return [keys %keyword_ids]; + return [values %keywords]; } sub _check_product { |