I'm trying to decide if this is a bug or a problem in my usage.

I use an "after prepare_body_parameters" method modifier that manipulates
the body parameters.  This quit working after moving to Catalyst 9.


The Engine code up to 5.80033 did this:

sub prepare_body_parameters {
    my ( $self, $c ) = @_;

    return unless $c->request->_body;

    $c->request->body_parameters( $c->request->_body->param );
}

And now 5.90010 does this:

before body_parameters => sub {
    my ($self) = @_;
    $self->prepare_body;
    $self->prepare_body_parameters;
};

sub prepare_body_parameters {
    my ( $self ) = @_;

    return unless $self->_body;

    $self->{body_parameters} = $self->_body->param; # FIXME!! Recursion here.
}


So, if my "after prepare_body_parameters" modifies the parameters and puts
the changes in $c->req->body_parameters, then next time
$c->req->body_parameters is called they get prepared again and my
modifications are overwritten.

Does body_parameters need a predicate and then do this?:

before body_parameters => sub {
    my ($self) = @_;

    return if $self->body_parameters_set;

    $self->prepare_body;
    $self->prepare_body_parameters;
};


The code above looks like it was trying to fix some flow problems
(populating the attribute directly as a hash, for example), so the real fix
is probably something else.  Perhaps a builder on body_parameters so that
it isn't populated every call.

This look like a bug?  Or should I not be adding method modifiers to
prepare_body_parameters?

BTW -- the reason I used "after prepare_body_parameters" is so that
$c->req->parameters ends up with any changes I make to the body_parameters.

-- 
Bill Moseley
[email protected]
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to