Deal correctly with app classes which are immutable in mod_perl
Tomas Doran [Sun, 24 Jul 2011 21:24:59 +0000 (22:24 +0100)]
Changes
lib/Catalyst.pm

diff --git a/Changes b/Changes
index fbbd97f..23279ba 100644 (file)
--- 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.
index bdb37bf..9287999 100644 (file)
@@ -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 );