[mp2] local %ENV causes $ENV{MOD_PERL} etc. to disappear on later requests

Tim Retout <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <CABdLK8smUA6uTQKCbB8s7+2Mu3dSF5T6=6gO462nNEBeUs-=UQ@mail.gmail.com>
Hello!

At work I have been having some trouble with localizing %ENV.  (This
happens in CPAN modules such as Plack::Handler::Apache2 amongst others.)

All seems well during the request itself - i.e. after the "local" goes out
of scope, %ENV is reset correctly.  However, on subsequent requests to the
same process, both MOD_PERL and MOD_PERL_API_VERSION are undefined.

We are running Debian wheezy, and have reproduced this from SVN r1600690
built against Debian's Apache.

This happens with "SetHandler perl-script", but not with "SetHandler
modperl".

Here is our minimal location block:

    <Location />
        SetHandler perl-script
        PerlResponseHandler handler
    </Location>

And our minimal handler:

package handler;

use strict;
use warnings;

use Apache2::Const -compile => qw(OK);
use Apache2::RequestRec;

sub handler {
    my $r = shift;

    no warnings 'uninitialized';

    warn "Before:\n";
    warn "MOD_PERL             => $ENV{MOD_PERL}\n";
    warn "MOD_PERL_API_VERSION => $ENV{MOD_PERL_API_VERSION}\n";

    {
        local %ENV;
    }

    warn "After:\n";
    warn "MOD_PERL             => $ENV{MOD_PERL}\n";
    warn "MOD_PERL_API_VERSION => $ENV{MOD_PERL_API_VERSION}\n\n";

    $r->content_type("text/plain");

    return Apache2::Const::OK;
}

1;

-- 
Tim Retout <[email protected]>
Development Manager, CV-Library
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.