From: Tomas Doran Date: Sun, 24 Jul 2011 21:24:59 +0000 (+0100) Subject: Deal correctly with app classes which are immutable in mod_perl X-Git-Tag: 5.89003~20 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=ab4df9f8c9261a664b604b054b5c52e377f99a8a Deal correctly with app classes which are immutable in mod_perl --- diff --git a/Changes b/Changes index fbbd97f..23279ba 100644 --- a/Changes +++ b/Changes @@ -9,6 +9,9 @@ Bug fixes: + - mod_perl handler fixed to work with application classes which have manually + been made immutable. + - Scripts now force the Plack engine choice manually, rather than relying on auto-detection, as the automatic mechanism gets it wrong if (for example) Coro is loaded. diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index bdb37bf..9287999 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -2626,12 +2626,19 @@ sub setup_engine { if ($ENV{MOD_PERL}) { my $apache = $class->engine_loader->auto; - # FIXME - Immutable - $class->meta->add_method(handler => sub { + + my $meta = find_meta($class); + my $was_immutable = $meta->is_immutable; + my %immutable_options = $meta->immutable_options; + $meta->make_mutable if $was_immutable; + + $meta->add_method(handler => sub { my $r = shift; my $psgi_app = $class->psgi_app; $apache->call_app($r, $psgi_app); }); + + $meta->make_immutable(%immutable_options) if $was_immutable; } $class->engine( $engine->new );