diff options
author | Byron Jones <glob@mozilla.com> | 2011-11-07 21:42:19 +0100 |
---|---|---|
committer | Dave Lawrence <dkl@mozilla.com> | 2011-11-07 21:42:19 +0100 |
commit | 1edbe81c97610ba39a5990d3e62fe11de699dbf2 (patch) | |
tree | 63ab082e85df637ddce7a612463ed54035d3687d | |
parent | ad5ec877dddbc34d0249610fb790896605da33df (diff) | |
download | bugzilla-1edbe81c97610ba39a5990d3e62fe11de699dbf2.tar.gz bugzilla-1edbe81c97610ba39a5990d3e62fe11de699dbf2.tar.xz |
Fix uninitialized value warning in REMO when cloning a bug
-rw-r--r-- | extensions/REMO/Extension.pm | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/extensions/REMO/Extension.pm b/extensions/REMO/Extension.pm index 166cac4f5..fa412d87e 100644 --- a/extensions/REMO/Extension.pm +++ b/extensions/REMO/Extension.pm @@ -187,6 +187,102 @@ sub post_bug_after_creation { my $bug = $vars->{bug}; my $template = Bugzilla->template; + if (Bugzilla->input_params->{format} + && Bugzilla->input_params->{format} eq 'remo-swag') + { + # 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); + + my $attachment; + eval { + my $xml; + $template->process("bug/create/create-remo-swag.xml.tmpl", {}, \$xml) + || ThrowTemplateError($template->error()); + + $attachment = Bugzilla::Attachment->create( + { bug => $bug, + creation_ts => $bug->creation_ts, + data => $xml, + description => 'Remo Swag Request (XML)', + filename => 'remo-swag.xml', + ispatch => 0, + isprivate => 0, + isurl => 0, + mimetype => 'text/xml', + store_in_file => 0, + }); + }; + + if ($attachment) { + # Insert comment for attachment + $bug->add_comment('', { isprivate => 0, + type => CMT_ATTACHMENT_CREATED, + extra_data => $attachment->id }); + $bug->update($bug->creation_ts); + } + else { + $vars->{'message'} = 'attachment_creation_failed'; + } + + Bugzilla->error_mode($error_mode_cache); + } +} + +sub post_bug_after_creation { + my ($self, $args) = @_; + my $vars = $args->{vars}; + my $bug = $vars->{bug}; + my $template = Bugzilla->template; + + if (Bugzilla->input_params->{format} eq 'remo-swag') { + # 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); + + my $attachment; + eval { + my $xml; + $template->process("bug/create/create-remo-swag.xml.tmpl", {}, \$xml) + || ThrowTemplateError($template->error()); + + $attachment = Bugzilla::Attachment->create( + { bug => $bug, + creation_ts => $bug->creation_ts, + data => $xml, + description => 'Remo Swag Request (XML)', + filename => 'remo-swag.xml', + ispatch => 0, + isprivate => 0, + isurl => 0, + mimetype => 'text/xml', + store_in_file => 0, + }); + }; + + if ($attachment) { + # Insert comment for attachment + $bug->add_comment('', { isprivate => 0, + type => CMT_ATTACHMENT_CREATED, + extra_data => $attachment->id }); + $bug->update($bug->creation_ts); + } + else { + $vars->{'message'} = 'attachment_creation_failed'; + } + + Bugzilla->error_mode($error_mode_cache); + } +} + +sub post_bug_after_creation { + my ($self, $args) = @_; + my $vars = $args->{vars}; + my $bug = $vars->{bug}; + my $template = Bugzilla->template; + if (Bugzilla->input_params->{format} eq 'remo-swag') { # If the attachment cannot be successfully added to the bug, # we notify the user, but we don't interrupt the bug creation process. |