[Catalyst] change in Engine prepare_body_parameters

Bill Moseley moseley at hank.org
Sat Apr 21 12:30:44 GMT 2012


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 ) =3D @_;

    return unless $c->request->_body;

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

And now 5.90010 does this:

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

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

    return unless $self->_body;

    $self->{body_parameters} =3D $self->_body->param; # FIXME!! Recursion h=
ere.
}


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 =3D> sub {
    my ($self) =3D @_;

    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
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20120421/1f32c=
0fc/attachment.htm


More information about the Catalyst mailing list