From: Rafael Kitover Date: Tue, 14 Dec 2010 09:56:40 +0000 (-0500) Subject: Fix a fail when very old Moose/CMOP is installed X-Git-Tag: 0.07003~23 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0dd4099ead263b588815f6a9b40de46454d09973;p=dbsrgits%2FDBIx-Class-Schema-Loader.git Fix a fail when very old Moose/CMOP is installed --- diff --git a/Changes b/Changes index 5f81d36..8a592de 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,6 @@ Revision history for Perl extension DBIx::Class::Schema::Loader + - Fix a fail when very old Moose/CMOP is installed - Added warning for column-accessor collisions, doc section in ::Base ("COLUMN ACCESSOR COLLISIONS") and the col_collision_map option. - Handle column accessor collisions with UNIVERSAL methods diff --git a/lib/DBIx/Class/Schema/Loader/Base.pm b/lib/DBIx/Class/Schema/Loader/Base.pm index a95ba83..62391c4 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -865,12 +865,7 @@ sub _load_external { warn qq/# Loaded external class definition for '$class'\n/ if $self->debug; - open(my $fh, '<', $real_inc_path) - or croak "Failed to open '$real_inc_path' for reading: $!"; - my $code = do { local $/; <$fh> }; - close($fh) - or croak "Failed to close $real_inc_path: $!"; - $code = $self->_rewrite_old_classnames($code); + my $code = $self->_rewrite_old_classnames(scalar slurp $real_inc_path); if ($self->dynamic) { # load the class too eval_without_redefine_warnings($code); @@ -1125,7 +1120,9 @@ sub _reload_classes { sub _moose_metaclass { return undef unless $INC{'Class/MOP.pm'}; # if CMOP is not loaded the class could not have loaded in the 1st place - my $mc = Class::MOP::class_of($_[1]) + my $class = $_[1]; + + my $mc = try { Class::MOP::class_of($class) } or return undef; return $mc->isa('Moose::Meta::Class') ? $mc : undef;