Merge remote-tracking branch 'upstream/master'
Charlie Garrison [Sun, 28 Sep 2014 02:52:48 +0000 (12:52 +1000)]
Changes
lib/Catalyst.pm
lib/Catalyst/Request.pm
lib/Catalyst/Runtime.pm
lib/Catalyst/Utils.pm
t/undef-params.t

diff --git a/Changes b/Changes
index 541f876..5c246ec 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,13 @@
 # This file documents the revision history for Perl extension Catalyst.
 
+5.90073 - 2014-09-23
+  - Fixed a regression caused by the last release where we broke what happened
+    when you tried to set request parameters via $c->req->param('foo', 'bar').
+    You shouldn't do this, but I guess I shouldn't have busted it either :)
+  - Allow the term_width to be regenerated (see Catalyst::Utils::term_width,
+    Frew Schmidt)
+  - More aggressive skipping of value decoding if the value is undefined.
+
 5.90072 - 2014-09-15
   - In the case where you call $c->req->param(undef), warn with a more useful
     warning (now gives the line of your code that called param with the undef,
index 69a49f1..471f9c3 100644 (file)
@@ -127,7 +127,7 @@ __PACKAGE__->stats_class('Catalyst::Stats');
 __PACKAGE__->_encode_check(Encode::FB_CROAK | Encode::LEAVE_SRC);
 
 # Remember to update this in Catalyst::Runtime as well!
-our $VERSION = '5.90072';
+our $VERSION = '5.90073';
 
 sub import {
     my ( $class, @arguments ) = @_;
@@ -3086,6 +3086,7 @@ sub _handle_unicode_decoding {
 
     return unless defined $value;
 
+    ## I think this mess is to support the old nested
     if ( ref $value eq 'ARRAY' ) {
         foreach ( @$value ) {
             $_ = $self->_handle_unicode_decoding($_);
@@ -3105,6 +3106,8 @@ sub _handle_unicode_decoding {
 
 sub _handle_param_unicode_decoding {
     my ( $self, $value ) = @_;
+    return unless defined $value; # not in love with just ignoring undefs - jnap
+
     my $enc = $self->encoding;
     return try {
         Encode::is_utf8( $value ) ?
index 39cc3a4..021bf24 100644 (file)
@@ -672,7 +672,7 @@ sub param {
     }
     elsif ( @params > 1 ) {
         my $field = shift @params;
-        $self->parameters->{$field} = [@_];
+        $self->parameters->{$field} = [@params];
     }
 }
 
index 446286f..fa9b74b 100644 (file)
@@ -7,7 +7,7 @@ BEGIN { require 5.008003; }
 
 # Remember to update this in Catalyst as well!
 
-our $VERSION = '5.90072';
+our $VERSION = '5.90073';
 
 =head1 NAME
 
index 78c293a..5ee7451 100644 (file)
@@ -384,11 +384,21 @@ that 'env' now lists COLUMNS.)
 
 As last resort, default value of 80 chars will be used.
 
+Calling C<term_width> with a true value will cause it to be recalculated; you
+can use this to cause it to get recalculated when your terminal is resized like
+this
+
+ $SIG{WINCH} = sub { Catalyst::Utils::term_width(1) };
+
 =cut
 
 my $_term_width;
 
 sub term_width {
+    my $force_reset = shift;
+
+    undef $_term_width if $force_reset;
+
     return $_term_width if $_term_width;
 
     my $width;
index 8ce8e2c..a6d7594 100644 (file)
@@ -22,6 +22,12 @@ use Plack::Test;
     $c->response->body("This is the body");
   }
 
+  sub set_params :Local {
+    my ($self, $c) = @_;
+    $c->req->param(foo => 'a', 'b', 'c');
+    $c->res->body(join ',', $c->req->param('foo'));
+  }
+
   package MyApp;
   use Catalyst;
 
@@ -37,8 +43,17 @@ ok my $psgi = MyApp->psgi_app, 'build psgi app';
 
 test_psgi $psgi, sub {
     my $cb = shift;
-    my $res = $cb->(GET "/root/test");
-    is $res->code, 200, 'OK';
+
+    {
+      my $res = $cb->(GET "/root/test");
+      is $res->code, 200, 'OK';
+    }
+
+    {
+      my $res = $cb->(GET "/root/set_params");
+      is $res->code, 200, 'OK';
+      is $res->content, 'a,b,c';
+    }
 };
 
 done_testing;