diff options
author | mkanat%bugzilla.org <> | 2006-09-16 07:18:46 +0000 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2006-09-16 07:18:46 +0000 |
commit | cc3a19cb43e162ede1237986ea535a42c03cb423 (patch) | |
tree | 5760e6bbfc34ca0e77481cc46dd1ced158a93159 /post_bug.cgi | |
parent | Bug 351958: Allow buidling the API documentation without the rest of the buil... (diff) | |
download | bugzilla-cc3a19cb43e162ede1237986ea535a42c03cb423.tar.gz bugzilla-cc3a19cb43e162ede1237986ea535a42c03cb423.tar.bz2 bugzilla-cc3a19cb43e162ede1237986ea535a42c03cb423.zip |
Bug 351888: Move comment creation out of post_bug.cgi and into Bugzilla::Bug
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=mkanat, a=myk
Diffstat (limited to 'post_bug.cgi')
-rwxr-xr-x | post_bug.cgi | 75 |
1 files changed, 16 insertions, 59 deletions
diff --git a/post_bug.cgi b/post_bug.cgi index 3be5e3ab6..74da0fd00 100755 --- a/post_bug.cgi +++ b/post_bug.cgi @@ -88,29 +88,6 @@ if ($token) { '^requestee_type-(\d+)$' => { 'type' => 'multi' }, }); -# The format of the initial comment can be structured by adding fields to the -# enter_bug template and then referencing them in the comment template. -my $comment; - -my $format = $template->get_format("bug/create/comment", - scalar($cgi->param('format')), "txt"); - -$template->process($format->{'template'}, $vars, \$comment) - || ThrowTemplateError($template->error()); - -# Check that the product exists and that the user -# is allowed to enter bugs into this product. -my $product = Bugzilla::Bug->_check_product($cgi->param('product')); - -# Set cookies -if (defined $cgi->param('product')) { - if (defined $cgi->param('version')) { - $cgi->send_cookie(-name => "VERSION-" . $product->name, - -value => $cgi->param('version'), - -expires => "Fri, 01-Jan-2038 00:00:00 GMT"); - } -} - if (defined $cgi->param('maketemplate')) { $vars->{'url'} = $cgi->query_string(); $vars->{'short_desc'} = $cgi->param('short_desc'); @@ -123,13 +100,6 @@ if (defined $cgi->param('maketemplate')) { umask 0; -# This has to go somewhere after 'maketemplate' -# or it breaks bookmarks with no comments. -$comment = Bugzilla::Bug->_check_comment($cgi->param('comment')); -# If comment is all whitespace, it'll be null at this point. That's -# OK except for the fact that it causes e-mail to be suppressed. -$comment = $comment ? $comment : " "; - # get current time my $timestamp = $dbh->selectrow_array(q{SELECT NOW()}); @@ -140,6 +110,14 @@ foreach my $group (grep(/^bit-\d+$/, $cgi->param())) { push(@selected_groups, $1); } +# The format of the initial comment can be structured by adding fields to the +# enter_bug template and then referencing them in the comment template. +my $comment; +my $format = $template->get_format("bug/create/comment", + scalar($cgi->param('format')), "txt"); +$template->process($format->{'template'}, $vars, \$comment) + || ThrowTemplateError($template->error()); + # Include custom fields editable on bug creation. my @custom_bug_fields = Bugzilla->get_fields( { custom => 1, obsolete => 0, enter_bug => 1 }); @@ -159,6 +137,7 @@ push(@bug_fields, qw( alias blocked + commentprivacy bug_file_loc bug_severity bug_status @@ -182,43 +161,21 @@ foreach my $field (@bug_fields) { $bug_params{'creation_ts'} = $timestamp; $bug_params{'cc'} = [$cgi->param('cc')]; $bug_params{'groups'} = \@selected_groups; - -# Add the bug report to the DB. -$dbh->bz_lock_tables('bugs WRITE', 'bug_group_map WRITE', 'longdescs WRITE', - 'cc WRITE', 'keywords WRITE', 'dependencies WRITE', - 'bugs_activity WRITE', 'groups READ', - 'user_group_map READ', 'group_group_map READ', - 'keyworddefs READ', 'fielddefs READ', - 'products READ', 'versions READ', 'milestones READ', - 'components READ', 'profiles READ', 'bug_severity READ', - 'op_sys READ', 'priority READ', 'rep_platform READ', - 'group_control_map READ', @custom_tables); +$bug_params{'comment'} = $comment; my $bug = Bugzilla::Bug->create(\%bug_params); # Get the bug ID back. my $id = $bug->bug_id; -# Add the initial comment, allowing for the fact that it may be private -my $privacy = 0; -if (Bugzilla->params->{"insidergroup"} - && Bugzilla->user->in_group(Bugzilla->params->{"insidergroup"})) -{ - $privacy = $cgi->param('commentprivacy') ? 1 : 0; +# Set Version cookie, but only if the user actually selected +# a version on the page. +if (defined $cgi->param('version')) { + $cgi->send_cookie(-name => "VERSION-" . $bug->product, + -value => $bug->version, + -expires => "Fri, 01-Jan-2038 00:00:00 GMT"); } -trick_taint($comment); -$dbh->do(q{INSERT INTO longdescs (bug_id, who, bug_when, thetext,isprivate) - VALUES (?, ?, ?, ?, ?)}, undef, ($id, $user->id, $timestamp, - $comment, $privacy)); - -# All fields related to the newly created bug are set. -# The bug can now be made accessible. -$dbh->do("UPDATE bugs SET creation_ts = ? WHERE bug_id = ?", - undef, ($timestamp, $id)); - -$dbh->bz_unlock_tables(); - # We don't have to check if the user can see the bug, because a user filing # a bug can always see it. You can't change reporter_accessible until # after the bug is filed. |