Fixed the fork and restart bug
[catagits/Catalyst-Runtime.git] / lib / Catalyst.pm
index 7d6e4fa..3ebbe97 100644 (file)
@@ -24,8 +24,7 @@ __PACKAGE__->mk_accessors(
 
 attributes->import( __PACKAGE__, \&namespace, 'lvalue' );
 
-sub depth { scalar @{shift->stack||[]}; }
-#sub namespace { my $a = shift->stack->[-1]; ($a ? $a->namespace : ''); }
+sub depth { scalar @{ shift->stack || [] }; }
 
 # Laziness++
 *comp = \&component;
@@ -44,7 +43,7 @@ our $DETACH    = "catalyst_detach\n";
 require Module::Pluggable::Fast;
 
 # Helper script generation
-our $CATALYST_SCRIPT_GEN = 10;
+our $CATALYST_SCRIPT_GEN = 11;
 
 __PACKAGE__->mk_classdata($_)
   for qw/components arguments dispatcher engine log dispatcher_class
@@ -55,7 +54,7 @@ __PACKAGE__->engine_class('Catalyst::Engine::CGI');
 __PACKAGE__->request_class('Catalyst::Request');
 __PACKAGE__->response_class('Catalyst::Response');
 
-our $VERSION = '5.49_03';
+our $VERSION = '5.49_04';
 
 sub import {
     my ( $class, @arguments ) = @_;
@@ -376,11 +375,13 @@ sub setup {
         }
     }
 
-    $class->log->warn( "You are running an old helper script! "
-          . "Please update your scripts by regenerating the "
-          . "application and copying over the new scripts." )
-      if ( $ENV{CATALYST_SCRIPT_GEN}
-        && ( $ENV{CATALYST_SCRIPT_GEN} < $Catalyst::CATALYST_SCRIPT_GEN ) );
+    $class->log->warn(
+        <<"EOF") if ( $ENV{CATALYST_SCRIPT_GEN} && ( $ENV{CATALYST_SCRIPT_GEN} < $Catalyst::CATALYST_SCRIPT_GEN ) );
+You are running an old script!
+
+  Please update by running:
+    catalyst.pl -nonew -scripts $class
+EOF
 
     if ( $class->debug ) {
 
@@ -844,7 +845,11 @@ sub execute {
     my ( $c, $class, $code ) = @_;
     $class = $c->components->{$class} || $class;
     $c->state(0);
-    my $callsub = ( caller(1) )[3];
+
+    my $callsub =
+        ( caller(0) )[0]->isa('Catalyst::Action')
+      ? ( caller(2) )[3]
+      : ( caller(1) )[3];
 
     my $action = '';
     if ( $c->debug ) {
@@ -862,7 +867,7 @@ sub execute {
 
         $action = "-> $action" if $callsub =~ /forward$/;
     }
-    push(@{$c->stack}, $code);
+    push( @{ $c->stack }, $code );
     eval {
         if ( $c->debug )
         {
@@ -879,7 +884,7 @@ sub execute {
             $c->state( &$code( $class, $c, @{ $c->req->args } ) || 0 );
         }
     };
-    pop(@{$c->stack});
+    pop( @{ $c->stack } );
 
     if ( my $error = $@ ) {
 
@@ -1390,7 +1395,7 @@ sub setup_components {
             return $component;
         }
 
-        my $suffix = Catalyst::Utils::class2classsuffix($class);
+        my $suffix = Catalyst::Utils::class2classsuffix($component);
         my $config = $class->config->{$suffix} || {};
 
         my $instance;
@@ -1670,6 +1675,10 @@ sub setup_plugins {
     }
 }
 
+=item $c->stack
+
+Contains the stack.
+
 =item $c->write( $data )
 
 Writes $data to the output stream.  When using this method directly, you will