$class = $c->component($class) || $class;
$c->state(0);
+ if ($c->depth >= $RECURSION) {
+ my $action = "$code";
+ $action = "/$action" unless $action =~ /\-\>/;
+ my $error = qq/Deep recursion detected calling "$action"/;
+ $c->log->error($error);
+ $c->error($error);
+ $c->state(0);
+ return $c->state;
+ }
+
+
if ( $c->debug ) {
my $action = "$code";
$action = "/$action" unless $action =~ /\-\>/;
$c->counter->{"$code"}++;
- if ( $c->counter->{"$code"} > $RECURSION ) {
- my $error = qq/Deep recursion detected in "$action"/;
- $c->log->error($error);
- $c->error($error);
- $c->state(0);
- return $c->state;
- }
-
# determine if the call was the result of a forward
# this is done by walking up the call stack and looking for a calling
# sub of Catalyst::forward before the eval
return $c->SUPER::execute(@_);
}
-sub class_forward_test_method {
+sub class_forward_test_method :Private {
my ( $self, $c ) = @_;
$c->response->headers->header( 'X-Class-Forward-Test-Method' => 1 );
}
+sub loop_test : Local {
+ my ( $self, $c ) = @_;
+
+ for( 1..1001 ) {
+ $c->forward( 'class_forward_test_method' );
+ }
+}
+
+sub recursion_test : Local {
+ my ( $self, $c ) = @_;
+ $c->forward( 'recursion_test' );
+}
+
{
no warnings 'redefine';
sub Catalyst::Log::error { }
--- /dev/null
+#!perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+use Test::More tests => 3;
+use Catalyst::Test 'TestApp';
+
+ok( my $response = request('http://localhost/loop_test'), 'Request' );
+ok( $response->is_success, 'Response Successful 2xx' );
+ok( $response->header('X-Class-Forward-Test-Method'), 'Loop OK' );
--- /dev/null
+#!perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+use Test::More tests => 3;
+use Catalyst::Test 'TestApp';
+
+ok( my $response = request('http://localhost/recursion_test'), 'Request' );
+ok( !$response->is_success, 'Response Not Successful' );
+is( $response->header('X-Catalyst-Error'), 'Deep recursion detected calling "/recursion_test"', 'Deep Recursion Detected' );