Skip Menu |

This queue is for tickets about the Catalyst-Runtime CPAN distribution.

Report information
The Basics
Id: 75607
Status: resolved
Priority: 0/
Queue: Catalyst-Runtime

People
Owner: Nobody in particular
Requestors: felliott [...] virginia.edu
Cc: chisel [...] chizography.net
AdminCc:

Bug Information
Severity: Important
Broken in: 5.90008-TRIAL
Fixed in: (no value)



Subject: $c->req->body_parameters deletes body_parameters
Hello, In Catalyst::Runtime 5.90010, calling $c->req->body_parameters overwrites the body_parameters attribute with an empty hashref. Attached is a failing test that demonstrates this. The bug seems to be in the body_parameters 'before' method modifier. I don't know enough about Catalyst internals, but should this be a builder for the body_parameters attribute instead? That way it would only be run once. I've written a patch for that case, and it passes all tests. Thank you for your time and have a great day! Cheers, Fitz Elliott (using perl 5.14.2 on OS X 10.6)
Subject: 0002-make-sure-body_parameters-is-only-initialized-once.patch
From 7a107d95c4679753e4a98d372fad547077ea8ce2 Mon Sep 17 00:00:00 2001 From: Fitz Elliott <fitz.elliott@gmail.com> Date: Wed, 7 Mar 2012 13:58:21 -0500 Subject: [PATCH 2/2] make sure body_parameters is only initialized once diff --git a/lib/Catalyst/Request.pm b/lib/Catalyst/Request.pm index 9c43407..5a67228 100644 --- a/lib/Catalyst/Request.pm +++ b/lib/Catalyst/Request.pm @@ -127,9 +127,15 @@ has body_parameters => ( is => 'rw', required => 1, lazy => 1, - default => sub { {} }, + builder => '_build_body_parameters', ); +sub _build_body_parameters { + my ($self) = @_; + $self->prepare_body; + $self->prepare_body_parameters; +}; + has uploads => ( is => 'rw', required => 1, @@ -175,12 +181,6 @@ sub prepare_parameters { $parameters; } -before body_parameters => sub { - my ($self) = @_; - $self->prepare_body; - $self->prepare_body_parameters; -}; - has _uploadtmp => ( is => 'ro', predicate => '_has_uploadtmp', -- 1.7.9.2
Subject: 0001-add-test-for-Catalyst-Request-body_parameters.patch
From c58d969d89c2172f56de71ae7e10601964409200 Mon Sep 17 00:00:00 2001 From: Fitz Elliott <fitz.elliott@gmail.com> Date: Wed, 7 Mar 2012 12:52:28 -0500 Subject: [PATCH 1/2] add test for Catalyst::Request::body_parameters() diff --git a/t/aggregate/live_engine_request_parameters.t b/t/aggregate/live_engine_request_parameters.t index 56a7074..e97ba81 100644 --- a/t/aggregate/live_engine_request_parameters.t +++ b/t/aggregate/live_engine_request_parameters.t @@ -6,7 +6,7 @@ use warnings; use FindBin; use lib "$FindBin::Bin/../lib"; -use Test::More tests => 53; +use Test::More tests => 54; use Catalyst::Test 'TestApp'; use Catalyst::Request; @@ -71,8 +71,6 @@ use HTTP::Request::Common; 'Content-Type' => 'application/x-www-form-urlencoded' ); - unshift( @{ $parameters->{a} }, 1, 2, 3 ); - ok( my $response = request($request), 'Request' ); ok( $response->is_success, 'Response Successful 2xx' ); is( $response->content_type, 'text/plain', 'Response Content-Type' ); @@ -84,6 +82,9 @@ use HTTP::Request::Common; ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' ); isa_ok( $creq, 'Catalyst::Request' ); is( $creq->method, 'POST', 'Catalyst::Request method' ); + is_deeply( $creq->body_parameters, $parameters, + 'Catalyst::Request body_parameters' ); + unshift( @{ $parameters->{a} }, 1, 2, 3 ); is_deeply( $creq->parameters, $parameters, 'Catalyst::Request parameters' ); is_deeply( $creq->arguments, [qw(a b)], 'Catalyst::Request arguments' ); -- 1.7.9.2
This is fixed (in a slightly different way) in commit d003ff83ac25ab0af3988de66867f73af54ff631 I added your test cases as b76e3717f2e1f4f7d7532a9c6ccf04791f373145 to ensure that this patch also fixes your issues, which it does. Thanks for the bug report! This is in master now and will be fixed in the next version.