From: Yuval Kogman Date: Thu, 3 Nov 2005 16:48:01 +0000 (+0000) Subject: Make behavior of Catalyst::Request::param truely CGI compatible X-Git-Tag: 5.7099_04~1031 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=a82c2894ea88511dd690442cb58d33d7a62cecf8 Make behavior of Catalyst::Request::param truely CGI compatible --- diff --git a/lib/Catalyst/Request.pm b/lib/Catalyst/Request.pm index f0732ab..d5cb9ed 100644 --- a/lib/Catalyst/Request.pm +++ b/lib/Catalyst/Request.pm @@ -278,10 +278,19 @@ Contains the request method (C, C, C, etc). Get request parameters with a CGI.pm-compatible param method. This is a method for accessing parameters in $c->req->parameters. - $value = $c->request->param('foo'); - @values = $c->request->param('foo'); + $value = $c->request->param( 'foo' ); + @values = $c->request->param( 'foo' ); @params = $c->request->param; +Like C, and B previous versions of Catalyst, passing multiple +arguments to this method, like this: + + $c->request( 'foo', 'bar', 'gorch', 'quxx' ); + +will set the parameter C to the multiple values C, C and +C. Previously this would have added C as another value to C +(creating it if it didn't exist before), and C as another value for C. + =cut sub param { @@ -310,23 +319,9 @@ sub param { : $self->parameters->{$param}; } } - - if ( @_ > 1 ) { - - while ( my ( $field, $value ) = splice( @_, 0, 2 ) ) { - - next unless defined $field; - - if ( exists $self->parameters->{$field} ) { - for ( $self->parameters->{$field} ) { - $_ = [$_] unless ref($_) eq "ARRAY"; - push( @$_, $value ); - } - } - else { - $self->parameters->{$field} = $value; - } - } + elsif ( @_ > 1 ) { + my $field = shift; + $self->parameters->{$field} = [@_]; } }