summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/BugUrl.pm8
-rw-r--r--Bugzilla/Config.pm3
-rw-r--r--Bugzilla/DB.pm3
-rw-r--r--Bugzilla/DB/Schema.pm11
-rw-r--r--Bugzilla/WebService/Server.pm12
5 files changed, 26 insertions, 11 deletions
diff --git a/Bugzilla/BugUrl.pm b/Bugzilla/BugUrl.pm
index 4724ae71a..a824d286d 100644
--- a/Bugzilla/BugUrl.pm
+++ b/Bugzilla/BugUrl.pm
@@ -16,6 +16,7 @@ use base qw(Bugzilla::Object);
use Bugzilla::Util;
use Bugzilla::Error;
use Bugzilla::Constants;
+use Module::Runtime qw(require_module);
use URI::QueryParam;
@@ -113,7 +114,7 @@ sub _do_list_select {
my $objects = $class->SUPER::_do_list_select(@_);
foreach my $object (@$objects) {
- eval "use " . $object->class; die $@ if $@;
+ require_module($object->class);
bless $object, $object->class;
}
@@ -133,8 +134,7 @@ sub class_for {
my $uri = URI->new($value);
foreach my $subclass ($class->SUB_CLASSES) {
- eval "use $subclass";
- die $@ if $@;
+ require_module($subclass);
return wantarray ? ($subclass, $uri) : $subclass
if $subclass->should_handle($uri);
}
@@ -145,7 +145,7 @@ sub class_for {
sub _check_class {
my ($class, $subclass) = @_;
- eval "use $subclass"; die $@ if $@;
+ require_module($subclass);
return $subclass;
}
diff --git a/Bugzilla/Config.pm b/Bugzilla/Config.pm
index 85779fa6b..1016d51e4 100644
--- a/Bugzilla/Config.pm
+++ b/Bugzilla/Config.pm
@@ -16,6 +16,7 @@ use Bugzilla::Constants;
use Bugzilla::Hook;
use Data::Dumper;
use File::Temp;
+use Module::Runtime qw(require_module);
# Don't export localvars by default - people should have to explicitly
# ask for it, as a (probably futile) attempt to stop code using it
@@ -35,7 +36,7 @@ sub _load_params {
my %hook_panels;
foreach my $panel (keys %$panels) {
my $module = $panels->{$panel};
- eval("require $module") || die $@;
+ require_module($module);
my @new_param_list = $module->get_param_list();
$hook_panels{lc($panel)} = { params => \@new_param_list };
}
diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm
index 142c241bf..87110aaaa 100644
--- a/Bugzilla/DB.pm
+++ b/Bugzilla/DB.pm
@@ -34,6 +34,7 @@ use List::Util qw(max);
use Scalar::Util qw(weaken);
use Storable qw(dclone);
use English qw(-no_match_vars);
+use Module::Runtime qw(require_module);
has [qw(dsn user pass attrs)] => (
is => 'ro',
@@ -174,7 +175,7 @@ sub _connect {
my $pkg_module = DB_MODULE->{lc($driver)}->{db};
# do the actual import
- eval ("require $pkg_module")
+ eval { require_module($pkg_module) }
|| die ("'$driver' is not a valid choice for \$db_driver in "
. " localconfig: " . $@);
diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm
index 67ee9071c..e1c19fa51 100644
--- a/Bugzilla/DB/Schema.pm
+++ b/Bugzilla/DB/Schema.pm
@@ -28,6 +28,8 @@ use Carp qw(confess);
use Digest::MD5 qw(md5_hex);
use Hash::Util qw(lock_value unlock_hash lock_keys unlock_keys);
use List::MoreUtils qw(firstidx natatime);
+use Try::Tiny;
+use Module::Runtime qw(require_module);
use Safe;
# Historical, needed for SCHEMA_VERSION = '1.00'
use Storable qw(dclone freeze thaw);
@@ -1876,9 +1878,12 @@ sub new {
if ($driver) {
(my $subclass = $driver) =~ s/^(\S)/\U$1/;
$class .= '::' . $subclass;
- eval "require $class;";
- die "The $class class could not be found ($subclass " .
- "not supported?): $@" if ($@);
+ try {
+ require_module($class);
+ }
+ catch {
+ die "The $class class could not be found ($subclass not supported?): $_";
+ };
}
die "$class is an abstract base class. Instantiate a subclass instead."
if ($class eq __PACKAGE__);
diff --git a/Bugzilla/WebService/Server.pm b/Bugzilla/WebService/Server.pm
index a76c4c48c..e02788911 100644
--- a/Bugzilla/WebService/Server.pm
+++ b/Bugzilla/WebService/Server.pm
@@ -11,12 +11,15 @@ use 5.10.1;
use strict;
use warnings;
+use Bugzilla::Logging;
use Bugzilla::Error;
use Bugzilla::Util qw(datetime_from);
use Digest::MD5 qw(md5_base64);
use Scalar::Util qw(blessed);
use Storable qw(freeze);
+use Module::Runtime qw(require_module);
+use Try::Tiny;
sub handle_login {
my ($self, $class, $method, $full_method) = @_;
@@ -30,8 +33,13 @@ sub handle_login {
Bugzilla->request_cache->{dont_persist_session} = 1;
}
- eval "require $class";
- ThrowCodeError('unknown_method', {method => $full_method}) if $@;
+ try {
+ require_module($class);
+ }
+ catch {
+ ThrowCodeError('unknown_method', {method => $full_method});
+ FATAL($_);
+ };
return if ($class->login_exempt($method)
and !defined Bugzilla->input_params->{Bugzilla_login});
Bugzilla->login();