From: Sebastian Riedel Date: Fri, 11 Nov 2005 10:39:11 +0000 (+0000) Subject: Fixed args handling in forward X-Git-Tag: 5.7099_04~957 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=138ce4c03ae1ffaf58c721057b3f37486ffbc178 Fixed args handling in forward --- diff --git a/Changes b/Changes index dcf020b..5d5409a 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,8 @@ Tis file documents the revision history for Perl extension Catalyst. 5.50 + - Fixed args handling in forward() + - Fixed forwarding to classes - Fixed catalyst.pl-generated Build.PL Makefile section. - Fixed relative forwarding - Fixed forward arrows in debug output diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index b44923b..1b64843 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -85,7 +85,12 @@ sub forward { return 0; } - my $arguments = ( ref( $_[-1] ) eq 'ARRAY' ) ? pop(@_) : $c->req->args; + my $local_args = 0; + my $arguments = []; + if ( ref( $_[-1] ) eq 'ARRAY' ) { + $arguments = pop(@_); + $local_args++; + } my $result; @@ -107,7 +112,11 @@ sub forward { $result = $c->get_action( $tail, $1 ); if ($result) { $command = $tail; - push( @{$arguments}, @extra_args ); + if ($local_args) { unshift( @{$arguments}, @extra_args ) } + else { + $local_args++; + $arguments = \@extra_args; + } last DESCEND; } unshift( @extra_args, $tail ); @@ -154,7 +163,7 @@ qq/Couldn't forward to command "$command". Invalid action or component./; } - local $c->request->{arguments} = [ @{$arguments} ]; + if ($local_args) { local $c->request->{arguments} = [ @{$arguments} ] } $result->execute($c);