Bug 61113, Bug 58633 - Error handling inside do()... Somewhat a crutch

git-svn-id: svn://svn.office.custis.ru/3rdparty/bugzilla.org/trunk@674 6955db30-a419-402b-8a0d-67ecbb4d7f56
master
vfilippov 2010-03-04 12:31:41 +00:00
parent debc0143cb
commit 221eb0d11b
4 changed files with 21 additions and 2 deletions

View File

@ -40,16 +40,23 @@ use overload '""' => sub { $_[0]->{message} };
my $HAVE_DEVEL_STACKTRACE = eval { require Devel::StackTrace };
our $IN_EVAL = 0;
# We cannot use $^S to detect if we are in an eval(), because mod_perl
# already eval'uates everything, so $^S = 1 in all cases under mod_perl!
sub _in_eval
{
my $in = -$IN_EVAL;
for (my $stack = 1; my $sub = (caller($stack))[3]; $stack++)
{
last if $sub =~ /^ModPerl/;
return 1 if $sub =~ /^\(eval\)/;
if ($sub =~ /^\(eval\)/)
{
$in++;
last if $in > 0;
}
}
return 0;
return $in > 0;
}
# build error message for printing into error log or sending to maintainer e-mail

View File

@ -186,7 +186,9 @@ sub post_bug {
$cgi->param(-name => 'inbound_email', -value => 1);
$Bugzilla::Error::IN_EVAL++;
my $bug_id = do 'post_bug.cgi';
$Bugzilla::Error::IN_EVAL--;
die $@ . "\n\nIncoming mail format for entering bugs:\n\@field = value\n\@field = value\n...\n\nBug text\n" if $@;
if ($fields{attachments} && @{$fields{attachments}})
{
@ -215,7 +217,9 @@ sub insert_attachments_for_bug
$cgi->param(text_attachment => $_->{payload});
$cgi->param(token => issue_session_token('createattachment:'));
debug_print("Inserting attachment for bug $bug_id");
$Bugzilla::Error::IN_EVAL++;
do 'attachment.cgi';
$Bugzilla::Error::IN_EVAL--;
debug_print($@) if $@;
}
}
@ -262,7 +266,9 @@ sub process_bug {
$cgi->param('longdesclength', scalar $bug->longdescs);
$cgi->param('token', issue_hash_token([$bug->id, $bug->delta_ts]));
$Bugzilla::Error::IN_EVAL++;
do 'process_bug.cgi';
$Bugzilla::Error::IN_EVAL--;
debug_print($@) if $@;
if ($fields{attachments} && @{$fields{attachments}})
{

View File

@ -358,6 +358,8 @@ sub get_row
$_ = $page->get_cell($row, $_);
$_ = $_ ? $_->value : '';
Encode::_utf8_on($_);
tr/‒–—/---/;
tr/―/-/;
trim($_);
} ($col_min .. $col_max) ];
}
@ -371,6 +373,7 @@ sub post_bug
my $um = Bugzilla->usage_mode;
Bugzilla->usage_mode(USAGE_MODE_EMAIL);
Bugzilla->error_mode(ERROR_MODE_WEBPAGE);
$Bugzilla::Error::IN_EVAL++;
unless ($fields_in->{version})
{
# угадаем версию
@ -409,6 +412,7 @@ sub post_bug
$cgi->param(-name => 'dontsendbugmail', -value => 1);
# и дёргаем post_bug.cgi
my $bug_id = do 'post_bug.cgi';
$Bugzilla::Error::IN_EVAL--;
Bugzilla->usage_mode($um);
$bugmail->{$bug_id} = Bugzilla->request_cache->{mailrecipients};
return $bug_id;

View File

@ -1661,6 +1661,8 @@
[% BLOCK object_name %]
[% IF class == "Bugzilla::User" %]
user
[% ELSIF class == "Bugzilla::Product" %]
product
[% ELSIF class == "Bugzilla::Component" %]
component
[% ELSIF class == "Bugzilla::Version" %]