Fix on demand parsing of ->req->parameters
Tomas Doran [Fri, 15 May 2009 09:41:11 +0000 (09:41 +0000)]
Changes
lib/Catalyst/Request.pm

diff --git a/Changes b/Changes
index a48da4b..6c64991 100644 (file)
--- a/Changes
+++ b/Changes
@@ -23,6 +23,8 @@
           to report 'Unknown Error' (t0m)
         - Support adding Moose::Roles to the plugin list. These are applied to
           MyApp after plugins have been pushed onto @ISA (t0m)
+        - Fix calling $c->req->parameters as the first thing you do when
+          parse_on_demand is on (t0m)
 
 5.80003 2009-04-29 16:23:53
         - Various POD tweaks. (hdp, dandv)
index 81bda0f..a488acd 100644 (file)
@@ -36,14 +36,6 @@ has headers => (
   lazy => 1,
 );
 
-# Moose TODO:
-# - Can we lose the before modifiers which just call prepare_body ?
-#   they are wasteful, slow us down and feel cluttery.
-# Can we call prepare_body at BUILD time?
-# Can we make _body an attribute, have the rest of 
-# these lazy build from there and kill all the direct hash access
-# in Catalyst.pm and Engine.pm?
-
 has _context => (
   is => 'rw',
   weak_ref => 1,
@@ -58,11 +50,6 @@ has body_parameters => (
   default => sub { {} },
 );
 
-before body_parameters => sub {
-  my ($self) = @_;
-  $self->_context->prepare_body();
-};
-
 has uploads => (
   is => 'rw',
   required => 1,
@@ -76,6 +63,20 @@ has parameters => (
   default => sub { {} },
 );
 
+# TODO:
+# - Can we lose the before modifiers which just call prepare_body ?
+#   they are wasteful, slow us down and feel cluttery.
+
+#  Can we make _body an attribute, have the rest of
+#  these lazy build from there and kill all the direct hash access
+#  in Catalyst.pm and Engine.pm?
+
+before $_ => sub {
+    my ($self) = @_;
+    my $context = $self->_context || return;
+    $context->prepare_body;
+} for qw/parameters body_parameters/;
+
 around parameters => sub {
     my ($orig, $self, $params) = @_;
     if ($params) {