From: Tomas Doran Date: Mon, 19 Apr 2010 02:41:57 +0000 (+0000) Subject: Bah, accidentally removed.. X-Git-Tag: 5.80023~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=3c642151bed1634a426c282c02c934b1962cb1f5;hp=0a2577a8c5e7fd34a7977ea2fc9267f9f888066d Bah, accidentally removed.. --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index f51bfb4..dab2c8f 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -2408,6 +2408,10 @@ sub setup_components { # we know M::P::O found a file on disk so this is safe Catalyst::Utils::ensure_class_loaded( $component, { ignore_loaded => 1 } ); + + # Needs to be done as soon as the component is loaded, as loading a sub-component + # (next time round the loop) can cause us to get the wrong metaclass.. + $class->_controller_init_base_classes($component); } for my $component (@comps) { @@ -2417,6 +2421,7 @@ sub setup_components { : $class->expand_component_module( $component, $config ); for my $component (@expanded_components) { next if $comps{$component}; + $class->_controller_init_base_classes($component); # Also cover inner packages $class->components->{ $component } = $class->setup_component($component); } } @@ -2469,6 +2474,19 @@ sub expand_component_module { =cut +# FIXME - Ugly, ugly hack to ensure the we force initialize non-moose base classes +# nearest to Catalyst::Controller first, no matter what order stuff happens +# to be loaded. There are TODO tests in Moose for this, see +# f2391d17574eff81d911b97be15ea51080500003 +sub _controller_init_base_classes { + my ($app_class, $component) = @_; + return unless $component->isa('Catalyst::Controller'); + foreach my $class ( reverse @{ mro::get_linear_isa($component) } ) { + Moose::Meta::Class->initialize( $class ) + unless find_meta($class); + } +} + sub setup_component { my( $class, $component ) = @_; diff --git a/t/lib/TestApp.pm b/t/lib/TestApp.pm index 3391a22..1e4d5c4 100644 --- a/t/lib/TestApp.pm +++ b/t/lib/TestApp.pm @@ -20,11 +20,6 @@ our $VERSION = '0.01'; TestApp->config( name => 'TestApp', root => '/some/dir' ); -# Test bug found when re-adjusting the metaclass compat code in Moose -# in 292360. Test added to Moose in 4b760d6, but leave this attribute -# above ->setup so we have some generated methods to be double sure. -has an_attribute_before_we_change_base_classes => ( is => 'ro'); - if ($::setup_leakchecker && eval { Class::MOP::load_class('CatalystX::LeakChecker'); 1 }) { with 'CatalystX::LeakChecker';