Fixed args handling in forward
Sebastian Riedel [Fri, 11 Nov 2005 10:39:11 +0000 (10:39 +0000)]
Changes
lib/Catalyst/Dispatcher.pm

diff --git a/Changes b/Changes
index dcf020b..5d5409a 100644 (file)
--- 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
index b44923b..1b64843 100644 (file)
@@ -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);