Commit a4528b84 authored by Frédéric Buclin's avatar Frédéric Buclin

Bug 703928: Bugzilla::Util should depend on Bugzilla::Error, not the opposite

r=dkl a=LpSolit
parent edaf6506
...@@ -30,7 +30,7 @@ use base qw(Exporter); ...@@ -30,7 +30,7 @@ use base qw(Exporter);
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::WebService::Constants; use Bugzilla::WebService::Constants;
use Bugzilla::Util; use Bugzilla::Hook;
use Carp; use Carp;
use Data::Dumper; use Data::Dumper;
...@@ -62,12 +62,13 @@ sub _throw_error { ...@@ -62,12 +62,13 @@ sub _throw_error {
my $datadir = bz_locations()->{'datadir'}; my $datadir = bz_locations()->{'datadir'};
# If a writable $datadir/errorlog exists, log error details there. # If a writable $datadir/errorlog exists, log error details there.
if (-w "$datadir/errorlog") { if (-w "$datadir/errorlog") {
require Bugzilla::Util;
require Data::Dumper; require Data::Dumper;
my $mesg = ""; my $mesg = "";
for (1..75) { $mesg .= "-"; }; for (1..75) { $mesg .= "-"; };
$mesg .= "\n[$$] " . time2str("%D %H:%M:%S ", time()); $mesg .= "\n[$$] " . time2str("%D %H:%M:%S ", time());
$mesg .= "$name $error "; $mesg .= "$name $error ";
$mesg .= remote_ip(); $mesg .= Bugzilla::Util::remote_ip();
$mesg .= Bugzilla->user->login; $mesg .= Bugzilla->user->login;
$mesg .= (' actually ' . Bugzilla->sudoer->login) if Bugzilla->sudoer; $mesg .= (' actually ' . Bugzilla->sudoer->login) if Bugzilla->sudoer;
$mesg .= "\n"; $mesg .= "\n";
...@@ -115,7 +116,6 @@ sub _throw_error { ...@@ -115,7 +116,6 @@ sub _throw_error {
{ {
# Clone the hash so we aren't modifying the constant. # Clone the hash so we aren't modifying the constant.
my %error_map = %{ WS_ERROR_CODE() }; my %error_map = %{ WS_ERROR_CODE() };
require Bugzilla::Hook;
Bugzilla::Hook::process('webservice_error_codes', Bugzilla::Hook::process('webservice_error_codes',
{ error_map => \%error_map }); { error_map => \%error_map });
my $code = $error_map{$error}; my $code = $error_map{$error};
...@@ -186,6 +186,8 @@ sub ThrowTemplateError { ...@@ -186,6 +186,8 @@ sub ThrowTemplateError {
# Try a template first; but if this one fails too, fall back # Try a template first; but if this one fails too, fall back
# on plain old print statements. # on plain old print statements.
if (!$template->process("global/code-error.html.tmpl", $vars)) { if (!$template->process("global/code-error.html.tmpl", $vars)) {
require Bugzilla::Util;
import Bugzilla::Util qw(html_quote);
my $maintainer = Bugzilla->params->{'maintainer'}; my $maintainer = Bugzilla->params->{'maintainer'};
my $error = html_quote($vars->{'template_error_msg'}); my $error = html_quote($vars->{'template_error_msg'});
my $error2 = html_quote($template->error()); my $error2 = html_quote($template->error());
......
...@@ -47,6 +47,7 @@ use base qw(Exporter); ...@@ -47,6 +47,7 @@ use base qw(Exporter);
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::RNG qw(irand); use Bugzilla::RNG qw(irand);
use Bugzilla::Error;
use Date::Parse; use Date::Parse;
use Date::Format; use Date::Format;
...@@ -639,10 +640,9 @@ sub get_text { ...@@ -639,10 +640,9 @@ sub get_text {
$vars ||= {}; $vars ||= {};
$vars->{'message'} = $name; $vars->{'message'} = $name;
my $message; my $message;
if (!$template->process('global/message.txt.tmpl', $vars, \$message)) { $template->process('global/message.txt.tmpl', $vars, \$message)
require Bugzilla::Error; || ThrowTemplateError($template->error());
Bugzilla::Error::ThrowTemplateError($template->error());
}
# Remove the indenting that exists in messages.html.tmpl. # Remove the indenting that exists in messages.html.tmpl.
$message =~ s/^ //gm; $message =~ s/^ //gm;
return $message; return $message;
...@@ -657,13 +657,10 @@ sub template_var { ...@@ -657,13 +657,10 @@ sub template_var {
my %vars; my %vars;
# Note: If we suddenly start needing a lot of template_var variables, # Note: If we suddenly start needing a lot of template_var variables,
# they should move into their own template, not field-descs. # they should move into their own template, not field-descs.
my $result = $template->process('global/field-descs.none.tmpl', $template->process('global/field-descs.none.tmpl',
{ vars => \%vars, in_template_var => 1 }); { vars => \%vars, in_template_var => 1 })
# Bugzilla::Error can't be "use"d in Bugzilla::Util. || ThrowTemplateError($template->error());
if (!$result) {
require Bugzilla::Error;
Bugzilla::Error::ThrowTemplateError($template->error);
}
$cache->{$lang} = \%vars; $cache->{$lang} = \%vars;
return $vars{$name}; return $vars{$name};
} }
...@@ -688,11 +685,8 @@ use constant UTF8_ACCIDENTAL => qw(shiftjis big5-eten euc-kr euc-jp); ...@@ -688,11 +685,8 @@ use constant UTF8_ACCIDENTAL => qw(shiftjis big5-eten euc-kr euc-jp);
sub detect_encoding { sub detect_encoding {
my $data = shift; my $data = shift;
if (!Bugzilla->feature('detect_charset')) { Bugzilla->feature('detect_charset')
require Bugzilla::Error; || ThrowCodeError('feature_disabled', { feature => 'detect_charset' });
Bugzilla::Error::ThrowCodeError('feature_disabled',
{ feature => 'detect_charset' });
}
require Encode::Detect::Detector; require Encode::Detect::Detector;
import Encode::Detect::Detector 'detect'; import Encode::Detect::Detector 'detect';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment