From: Jos Boumans Date: Fri, 20 Mar 2009 20:21:00 +0000 (+0000) Subject: * must use $UNIVERSAL::require::ERROR, $@ is not safe. See RT #44444 X-Git-Tag: 0.04006~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fa1c4dc2daa12d97025beafdaf9dd576edcabc52;p=dbsrgits%2FDBIx-Class-Schema-Loader.git * must use $UNIVERSAL::require::ERROR, $@ is not safe. See RT #44444 --- diff --git a/lib/DBIx/Class/Schema/Loader/Base.pm b/lib/DBIx/Class/Schema/Loader/Base.pm index c6b89dd..45c66e9 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -299,10 +299,10 @@ sub _load_external { my $real_inc_path = Cwd::abs_path($inc_path); return if $real_inc_path eq $real_dump_path; - $class->require; - croak "Failed to load external class definition" - . " for '$class': $@" - if $@; + # must use $UNIVERSAL::require::ERROR, $@ is not safe. See RT #44444 --kane + $class->require or + croak "Failed to load external class definition" + . " for '$class': $UNIVERSAL::require::ERROR"; # If we make it to here, we loaded an external definition warn qq/# Loaded external class definition for '$class'\n/ @@ -584,7 +584,7 @@ sub _use { foreach (@_) { warn "$target: use $_;" if $self->debug; $self->_raw_stmt($target, "use $_;"); - $_->require or croak ($_ . "->require: $@"); + $_->require or croak ($_ . "->require: $UNIVERSAL::require::ERROR"); $evalstr .= "package $target; use $_;"; } eval $evalstr if $evalstr; @@ -600,7 +600,7 @@ sub _inject { warn "$target: use base qw/ $blist /;" if $self->debug && @_; $self->_raw_stmt($target, "use base qw/ $blist /;") if @_; foreach (@_) { - $_->require or croak ($_ . "->require: $@"); + $_->require or croak ($_ . "->require: $UNIVERSAL::require::ERROR"); $schema_class->inject_base($target, $_); } } diff --git a/lib/DBIx/Class/Schema/Loader/DBI.pm b/lib/DBIx/Class/Schema/Loader/DBI.pm index 5c90f6f..747e45d 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI.pm @@ -40,8 +40,12 @@ sub new { my $dbh = $self->schema->storage->dbh; my $driver = $dbh->{Driver}->{Name}; my $subclass = 'DBIx::Class::Schema::Loader::DBI::' . $driver; + + # must use $UNIVERSAL::require::ERROR, $@ is not safe. See RT #44444 --kane $subclass->require; - if($@ && $@ !~ /^Can't locate /) { + if($UNIVERSAL::require::ERROR && + $UNIVERSAL::require::ERROR !~ /^Can't locate / + ) { croak "Failed to require $subclass: $@"; } elsif(!$@) {