Skip Menu |

This queue is for tickets about the ModPerl-VersionUtil CPAN distribution.

Report information
The Basics
Id: 24112
Status: open
Priority: 0/
Queue: ModPerl-VersionUtil

People
Owner: Nobody in particular
Requestors: cmanley [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 0.01
  • 0.02
Fixed in: (no value)



The current code will return incorrect values in an external script called from a mod_perl script that inherits the environment. Below is what I believe is the correct code for the BEGIN block. Two things have changed: 1. %INC is also checked. 2. an undefined value in $ENV{MOD_PERL} won't cause warnings anymore. I've tested it in mod_perl2. I've guessed the %INC check for mod_perl1 from memory, so that needs to be double checked by someone running mod_perl1. BEGIN { foreach (qw(mp_version mp_version_string is_mp is_mp1 is_mp19 is_mp2)) { __PACKAGE__->mk_classdata($_); } if (my $version = $ENV{MOD_PERL}) { # Note: This environment variable could be set in an external script called from mod_perl, # so don't presume we are in mod_perl just yet. ($version) = $version =~ /^\S+\/(\d+(?:[\.\_]\d+)+)/; __PACKAGE__->mp_version_string($version); $version =~ s/_//g; $version =~ s/(\.[^.]+)\./$1/g; __PACKAGE__->mp_version($version); # Check for mod_perl2: if ($ENV{MOD_PERL_API_VERSION} && ($ENV{MOD_PERL_API_VERSION} == 2) && exists($INC{'Apache2/RequestRec.pm'})) { __PACKAGE__->is_mp(1); __PACKAGE__->is_mp2(1); } # Check for mod_perl1: elsif (exists($INC{'Apache.pm'})) { __PACKAGE__->is_mp(1); if ( $version >= 1.9901 ) { __PACKAGE__->is_mp19(1); } elsif ( $version >= 1.24 ) { __PACKAGE__->is_mp1(1); } } } }
Subject: The BEGIN block with indentation.
See attachment.
BEGIN { foreach (qw(mp_version mp_version_string is_mp is_mp1 is_mp19 is_mp2)) { __PACKAGE__->mk_classdata($_); } if (my $version = $ENV{MOD_PERL}) { # Note: This environment variable could be set in an external script called from mod_perl, # so don't presume we are in mod_perl just yet. ($version) = $version =~ /^\S+\/(\d+(?:[\.\_]\d+)+)/; __PACKAGE__->mp_version_string($version); $version =~ s/_//g; $version =~ s/(\.[^.]+)\./$1/g; __PACKAGE__->mp_version($version); # Check for mod_perl2: if ($ENV{MOD_PERL_API_VERSION} && ($ENV{MOD_PERL_API_VERSION} == 2) && exists($INC{'Apache2/RequestRec.pm'})) { __PACKAGE__->is_mp(1); __PACKAGE__->is_mp2(1); } # Check for mod_perl1: elsif (exists($INC{'Apache.pm'})) { __PACKAGE__->is_mp(1); if ( $version >= 1.9901 ) { __PACKAGE__->is_mp19(1); } elsif ( $version >= 1.24 ) { __PACKAGE__->is_mp1(1); } } } }