diff options
author | lpsolit%gmail.com <> | 2006-07-25 08:22:53 +0200 |
---|---|---|
committer | lpsolit%gmail.com <> | 2006-07-25 08:22:53 +0200 |
commit | 2904ac3261ff9bb59e29b74d55d4ada294986ffe (patch) | |
tree | c3c5b3a99f23f76502eac1e652044a550ba19371 /post_bug.cgi | |
parent | bea873a66d06670af744b29d9e8d357ae3b5ceed (diff) | |
download | bugzilla-2904ac3261ff9bb59e29b74d55d4ada294986ffe.tar.gz bugzilla-2904ac3261ff9bb59e29b74d55d4ada294986ffe.tar.xz |
Bug 174039: Set flags on bug entry - Patch by Frédéric Buclin <LpSolit@gmail.com> r=wurblzap r=myk a=myk
Diffstat (limited to 'post_bug.cgi')
-rwxr-xr-x | post_bug.cgi | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/post_bug.cgi b/post_bug.cgi index 083f577ac..6fb054c9f 100755 --- a/post_bug.cgi +++ b/post_bug.cgi @@ -536,11 +536,13 @@ $dbh->do("UPDATE bugs SET creation_ts = ? WHERE bug_id = ?", $dbh->bz_unlock_tables(); +my $bug = new Bugzilla::Bug($id, $user->id); + # 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, - $id, $user, $timestamp, + $bug, $user, $timestamp, \$vars) || ($vars->{'message'} = 'attachment_creation_failed'); @@ -551,11 +553,30 @@ 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 to be in batch mode. +# XXX: this can go away as soon as flag validation is able to +# fail without dying. +Bugzilla->batch(1); +eval { + # Make sure no flags have already been set for this bug. + # Impossible? - Well, depends if you hack the URL or not. + # Passing a bug ID of 0 will make it complain if it finds one. + Bugzilla::Flag::validate($cgi, 0); + Bugzilla::FlagType::validate($cgi, $id); + Bugzilla::Flag::process($bug, undef, $timestamp, $cgi); +}; +Bugzilla->batch(0); +if ($@) { + $vars->{'message'} = 'flag_creation_failed'; + $vars->{'flag_creation_error'} = $@; +} + # Email everyone the details of the new bug $vars->{'mailrecipients'} = {'changer' => $user->login}; $vars->{'id'} = $id; -my $bug = new Bugzilla::Bug($id, $user->id); $vars->{'bug'} = $bug; ThrowCodeError("bug_error", { bug => $bug }) if $bug->error; |