summaryrefslogtreecommitdiffstats
path: root/new_bug.cgi
diff options
context:
space:
mode:
authorSebastin Santy <sebastinssanty@gmail.com>2017-07-28 22:34:41 +0200
committerDylan William Hardison <dylan@hardison.net>2017-07-28 22:34:41 +0200
commite74d21eaeb3bc4ba3a5521882815b6a6c6d45bcc (patch)
treed46e54a47afdbc205cef58697de51da67b2687ca /new_bug.cgi
parentdc378846874cca43be0a187d7c38d787395a6538 (diff)
downloadbugzilla-e74d21eaeb3bc4ba3a5521882815b6a6c6d45bcc.tar.gz
bugzilla-e74d21eaeb3bc4ba3a5521882815b6a6c6d45bcc.tar.xz
Bug 1383268 - Add attachments to new-bug
Diffstat (limited to 'new_bug.cgi')
-rw-r--r--new_bug.cgi30
1 files changed, 30 insertions, 0 deletions
diff --git a/new_bug.cgi b/new_bug.cgi
index 7f35f9ebc..6a62d0dcb 100644
--- a/new_bug.cgi
+++ b/new_bug.cgi
@@ -45,6 +45,8 @@ my $user = Bugzilla->login(LOGIN_REQUIRED);
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
+my $dbh = Bugzilla->dbh;
+
unless ($user->in_group('new-bug-testers')) {
print $cgi->redirect(correct_urlbase());
@@ -70,6 +72,34 @@ if (lc($cgi->request_method) eq 'post') {
});
delete_token($token);
+ my $data_fh = $cgi->upload('data');
+
+ if ($data_fh) {
+ my $content_type = Bugzilla::Attachment::get_content_type();
+ my $attachment;
+
+ my $error_mode_cache = Bugzilla->error_mode;
+ Bugzilla->error_mode(ERROR_MODE_DIE);
+ my $timestamp = $dbh->selectrow_array(
+ 'SELECT creation_ts FROM bugs WHERE bug_id = ?', undef, $new_bug->bug_id);
+ eval {
+ $attachment = Bugzilla::Attachment->create(
+ {bug => $new_bug,
+ creation_ts => $timestamp,
+ data => $data_fh,
+ description => scalar $cgi->param('description'),
+ filename => $data_fh,
+ ispatch => 0,
+ isprivate => 0,
+ mimetype => $content_type,
+ });
+ };
+ Bugzilla->error_mode($error_mode_cache);
+ unless ($attachment) {
+ $vars->{'message'} = 'attachment_creation_failed';
+ }
+ }
+
my $recipients = { changer => $user };
my $bug_sent = Bugzilla::BugMail::Send($new_bug->bug_id, $recipients);
$bug_sent->{type} = 'created';