I should have mentioned in this bug report that the problem only occurs
when you call $r->param in a list context.  Everything is fine in a
scalar context.  For that reason I suspect this little bit of code:

sub param {
    my $self = shift;
    my($name, $value) = @_;
    my $tab = $self->parms;
    unless ($name) {
        my %seen;
        return wantarray ? grep { !$seen{$_}++ } keys %$tab : $tab;
    }
    if (defined $value) {
        $tab->set($name, $value);
    }
    return wantarray ? ($tab->get($name)) : scalar $tab->get($name);
}

-jwb

Jeffrey Baker wrote:
> 
> Hi,
> 
> I haven't had time to really hunt this bug to its source, but here is
> the report anyway.
> 
> Take as an example the URI /program?foo=bar&foo=baz&foo=quux
> 
> In program, which uses libapreq, I have code which looks like this:
> 
> my @foo_in = $r->param('foo');
> 
> @foo_in should not be defined if there are no foo arguments in the query
> string.  The problem is that once a foo argument has been seen, the
> @foo_in array is defined in that Apache child process for all time.  The
> array will not be defined in any other Apache child.
> 
> To reproduce the problem, use the handler I have included below and
> perform the following steps:
> 
> 1) Visit /yoururl
> 2) Visit /yoururl?foo=bar&foo=baz
> 3) Visit /yoururl as many times as you have Apache child processes
> 
> Here is the handler:
> 
> package JWB;
> use Apache::Request;
> 
> use strict;
> 
> sub handler {
>         my $r = Apache::Request->new(shift());
>         $r->status(200);
>         $r->content_type("text/plain");
>         $r->send_http_header;
> 
>         my @foo_in = $r->param('foo');
> 
>         if (defined @foo_in) {
>                 print "foo_in is defined!\n";
>         }
>         else {
>                 print "foo_in is not defined!\n";
>         }
> 
>         print "foo_in has this many entries: ",scalar(@foo_in);
> 
>         return 0;
> }
> 
> 1;
> 
> Regards,
> Jeffrey

Reply via email to