summaryrefslogtreecommitdiffstats
path: root/post_bug.cgi
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2006-12-30 07:18:54 +0100
committerlpsolit%gmail.com <>2006-12-30 07:18:54 +0100
commitc712d457006fbf7c29bd621549db7a732131ecb8 (patch)
tree962bfdd90744295a3b1eaf0b30ed947d75297e4f /post_bug.cgi
parent840eaae09a5f1118e290db7c6a38441eabb953dc (diff)
downloadbugzilla-c712d457006fbf7c29bd621549db7a732131ecb8.tar.gz
bugzilla-c712d457006fbf7c29bd621549db7a732131ecb8.tar.xz
Bug 346121: Creating an attachment upon new bug doesn't create attachment link in comment #0 - Patch by Frédéric Buclin <LpSolit@gmail.com> r=bkor a=justdave
Diffstat (limited to 'post_bug.cgi')
-rwxr-xr-xpost_bug.cgi24
1 files changed, 20 insertions, 4 deletions
diff --git a/post_bug.cgi b/post_bug.cgi
index 715437141..2c40a4441 100755
--- a/post_bug.cgi
+++ b/post_bug.cgi
@@ -187,10 +187,26 @@ if (defined $cgi->param('version')) {
# Add an attachment if requested.
if (defined($cgi->upload('data')) || $cgi->param('attachurl')) {
$cgi->param('isprivate', $cgi->param('commentprivacy'));
- Bugzilla::Attachment->insert_attachment_for_bug(!THROW_ERROR,
- $bug, $user, $timestamp,
- \$vars)
- || ($vars->{'message'} = 'attachment_creation_failed');
+ my $attach_id = Bugzilla::Attachment->insert_attachment_for_bug(!THROW_ERROR,
+ $bug, $user, $timestamp, \$vars);
+
+ if ($attach_id) {
+ # Update the comment to include the new attachment ID.
+ # This string is hardcoded here because Template::quoteUrls()
+ # expects to find this exact string.
+ my $new_comment = "Created an attachment (id=$attach_id)\n" .
+ $cgi->param('description') . "\n";
+ # We can use $bug->longdescs here because we are sure that the bug
+ # description is of type CMT_NORMAL. No need to include it if it's
+ # empty, though.
+ if ($bug->longdescs->[0]->{'body'} !~ /^\s+$/) {
+ $new_comment .= "\n" . $bug->longdescs->[0]->{'body'};
+ }
+ $bug->update_comment($bug->longdescs->[0]->{'id'}, $new_comment);
+ }
+ else {
+ $vars->{'message'} = 'attachment_creation_failed';
+ }
# Determine if Patch Viewer is installed, for Diff link
eval {