From: Andy Grundman Date: Mon, 9 Jan 2006 17:19:10 +0000 (+0000) Subject: Better solution for forward detection when dealing with plugins that extend execute X-Git-Tag: 5.7099_04~754 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=9d17368e8d5a29c37d3a98332da6a00976643a49 Better solution for forward detection when dealing with plugins that extend execute --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 0226ba1..59b30c2 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -934,15 +934,20 @@ sub execute { } # determine if the call was the result of a forward - my $callsub_index = ( caller(0) )[0]->isa('Catalyst::Action') ? 2 : 1; - if ( ( caller($callsub_index) )[3] =~ /^NEXT/ ) { - - # work around NEXT if execute was extended by a plugin - $callsub_index += 3; + # this is done by walking up the call stack and looking for a calling + # sub of Catalyst::forward before the eval + my $callsub = q{}; + for my $index (1..10) { + last + if ( ( caller($index) )[0] eq 'Catalyst' + && ( caller($index) )[3] eq '(eval)' ); + + if ( (caller($index))[3] =~ /forward$/ ) { + $callsub = (caller($index))[3]; + $action = "-> $action"; + last; + } } - my $callsub = ( caller($callsub_index) )[3]; - - $action = "-> $action" if $callsub =~ /forward$/; my $node = Tree::Simple->new( {