summaryrefslogtreecommitdiffstats
path: root/post_bug.cgi
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2009-04-09 13:37:56 +0200
committerlpsolit%gmail.com <>2009-04-09 13:37:56 +0200
commit719303d9928bf0a727478c32f83a39b015a25136 (patch)
treef1b91f5e441fcba753483298426893d0927154fb /post_bug.cgi
parent4afa077fc379af8eeec47f3dbd245b7c8fa9ff80 (diff)
downloadbugzilla-719303d9928bf0a727478c32f83a39b015a25136.tar.gz
bugzilla-719303d9928bf0a727478c32f83a39b015a25136.tar.xz
Bug 454251: Implement Bugzilla::Attachment->create() and $attachment->update() - Patch by Frédéric Buclin <LpSolit@gmail.com> a=LpSolit (module owner)
Diffstat (limited to 'post_bug.cgi')
-rwxr-xr-xpost_bug.cgi51
1 files changed, 30 insertions, 21 deletions
diff --git a/post_bug.cgi b/post_bug.cgi
index b450a8691..9a933fc1a 100755
--- a/post_bug.cgi
+++ b/post_bug.cgi
@@ -85,12 +85,10 @@ if ($token) {
}
# do a match on the fields if applicable
-
-&Bugzilla::User::match_field ($cgi, {
+Bugzilla::User::match_field ($cgi, {
'cc' => { 'type' => 'multi' },
'assigned_to' => { 'type' => 'single' },
'qa_contact' => { 'type' => 'single' },
- '^requestee_type-(\d+)$' => { 'type' => 'multi' },
});
if (defined $cgi->param('maketemplate')) {
@@ -194,10 +192,35 @@ if (defined $cgi->param('version')) {
# Add an attachment if requested.
if (defined($cgi->upload('data')) || $cgi->param('attachurl')) {
$cgi->param('isprivate', $cgi->param('commentprivacy'));
- my $attachment = Bugzilla::Attachment->create(!THROW_ERROR,
- $bug, $user, $timestamp, $vars);
+
+ # Must be called before create() as it may alter $cgi->param('ispatch').
+ my $content_type = Bugzilla::Attachment::get_content_type();
+ my $attachment;
+
+ # If the attachment cannot be successfully added to the bug,
+ # we notify the user, but we don't interrupt the bug creation process.
+ my $error_mode_cache = Bugzilla->error_mode;
+ Bugzilla->error_mode(ERROR_MODE_DIE);
+ eval {
+ $attachment = Bugzilla::Attachment->create(
+ {bug => $bug,
+ creation_ts => $timestamp,
+ data => scalar $cgi->param('attachurl') || $cgi->upload('data'),
+ description => scalar $cgi->param('description'),
+ filename => $cgi->param('attachurl') ? '' : scalar $cgi->upload('data'),
+ ispatch => scalar $cgi->param('ispatch'),
+ isprivate => scalar $cgi->param('isprivate'),
+ isurl => scalar $cgi->param('attachurl'),
+ mimetype => $content_type,
+ store_in_file => scalar $cgi->param('bigfile'),
+ });
+ };
+ Bugzilla->error_mode($error_mode_cache);
if ($attachment) {
+ # Set attachment flags.
+ Bugzilla::Flag->set_flags($bug, $attachment, $timestamp, $vars);
+
# Update the comment to include the new attachment ID.
# This string is hardcoded here because Template::quoteUrls()
# expects to find this exact string.
@@ -222,22 +245,8 @@ if (defined($cgi->upload('data')) || $cgi->param('attachurl')) {
};
}
-# Add flags, if any. To avoid dying if something goes wrong
-# while processing flags, we will eval() flag validation.
-# This requires errors to die().
-# XXX: this can go away as soon as flag validation is able to
-# fail without dying.
-my $error_mode_cache = Bugzilla->error_mode;
-Bugzilla->error_mode(ERROR_MODE_DIE);
-eval {
- Bugzilla::Flag::validate($id, undef, SKIP_REQUESTEE_ON_ERROR);
- Bugzilla::Flag->process($bug, undef, $timestamp, $vars);
-};
-Bugzilla->error_mode($error_mode_cache);
-if ($@) {
- $vars->{'message'} = 'flag_creation_failed';
- $vars->{'flag_creation_error'} = $@;
-}
+# Set bug flags.
+Bugzilla::Flag->set_flags($bug, undef, $timestamp, $vars);
# Email everyone the details of the new bug
$vars->{'mailrecipients'} = {'changer' => $user->login};