From 9e33be169d1ffe552a7c375db418ebd81f6ea7ec Mon Sep 17 00:00:00 2001 From: lnation Date: Sat, 23 Sep 2023 06:58:13 +0100 Subject: [PATCH] Closes optionally_keep_mod_perl_in_env --- lib/Plack/Handler/Apache2.pm | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/Plack/Handler/Apache2.pm b/lib/Plack/Handler/Apache2.pm index b5b543a72..5580783ec 100644 --- a/lib/Plack/Handler/Apache2.pm +++ b/lib/Plack/Handler/Apache2.pm @@ -26,19 +26,20 @@ sub preload { } sub load_app { - my($class, $app) = @_; + my($class, $app, $share) = @_; return $apps{$app} ||= do { - # Trick Catalyst, CGI.pm, CGI::Cookie and others that check - # for $ENV{MOD_PERL}. - # - # Note that we delete it instead of just localizing - # $ENV{MOD_PERL} because some users may check if the key - # exists, and we do it this way because "delete local" is new - # in 5.12: - # http://perldoc.perl.org/5.12.0/perldelta.html#delete-local - local $ENV{MOD_PERL}; - delete $ENV{MOD_PERL}; - + unless ($share || $ENV{SHARE_MOD_PERL}) { + # Trick Catalyst, CGI.pm, CGI::Cookie and others that check + # for $ENV{MOD_PERL}. + # + # Note that we delete it instead of just localizing + # $ENV{MOD_PERL} because some users may check if the key + # exists, and we do it this way because "delete local" is new + # in 5.12: + # http://perldoc.perl.org/5.12.0/perldelta.html#delete-local + local $ENV{MOD_PERL}; + delete $ENV{MOD_PERL}; + } Plack::Util::load_psgi $app; }; } @@ -123,7 +124,7 @@ sub handler { my $class = __PACKAGE__; my $r = shift; my $psgi = $r->dir_config('psgi_app'); - $class->call_app($r, $class->load_app($psgi)); + $class->call_app($r, $class->load_app($psgi, $r->dir_config('share_mod_perl'))); } # The method for PH::Apache2::Registry to override.